使用Maps api v2,它与4.4,5.0,5.1,5.1.1,6完美配合,但是当我尝试4.2.2时应用程序崩溃.我一直在做很多研究,但似乎没有任何效果.这是完整的日志.
FATAL EXCEPTION: main
java.lang.NoClassDefFoundError: com.google.android.gms.common.
at com.google.android.gms.measurement.internal.zzk$zza.get(
at com.google.android.gms.measurement.internal.zzc.zzkG(
at com.google.android.gms.measurement.internal.zzr.<init>(
at com.google.android.gms.measurement.internal.zzx.zzb(
at com.google.android.gms.measurement.internal.zzt.<init>(
at com.google.android.gms.measurement.internal.zzx.zzBQ(
at com.google.android.gms.measurement.internal.zzt.zzaU(
at com.google.android.gms.measurement.ource)
at android.content.ContentProvider.attachInfo(ContentProvider
at android.app.ActivityThread.installProvider(ActivityThread.
at android.app.ActivityThread.installContentProviders(
at android.app.ActivityThread.handleBindApplication(
at android.app.ActivityThread.access$1300(ActivityThread.
at android.app.ActivityThread$H.handleMessage(ActivityThread.
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:5041)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run
at com.android.internal.os.ZygoteInit.main(ZygoteInit.
at dalvik.system.NativeStart.main(Native Method)
有任何想法吗?
这是我的build.gradle
buildscript {
repositories {
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
classpath 'io.fabric.tools:gradle:1.+'
}
}
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
repositories {
mavenCentral()
maven {
url "http://dl.bintray.com/glomadrian/maven"
}
maven { url 'https://maven.fabric.io/public' }
}
android {
compileSdkVersion 23
buildToolsVersion "23.0.1"
defaultConfig {
applicationId "py.com.roshka.billeterabancard"
minSdkVersion 14
targetSdkVersion 23
versionCode 1
versionName "1.0"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.wang.avi:library:1.0.1'
compile 'com.nineoldandroids:library:2.4.0'
compile 'com.github.glomadrian:loadingballs:1.1@aar'
compile 'com.android.support:appcompat-v7:23.1.0'
compile 'com.google.android.gms:play-services:8.4.0'
compile 'com.android.support:design:23.1.0'
compile 'com.android.support:recyclerview-v7:23.1.0'
compile 'com.squareup.okio:okio:1.0.+'
compile 'com.squareup.okhttp:okhttp:1.5.4'
compile 'com.squareup.okhttp:okhttp-urlconnection:2.0.0'
compile 'com.squareup.retrofit:retrofit:1.8.0'
compile 'com.pnikosis:materialish-progress:1.7'
compile 'com.google.code.gson:gson:2.3'
compile 'me.dm7.barcodescanner:zxing:1.8.3'
compile 'me.dm7.barcodescanner:zbar:1.8.3'
compile('com.crashlytics.sdk.android:crashlytics:2.5.5@aar') {
transitive = true;
}
}
解决方法:
3个简单步骤:
第1步:
Multidexing是一项新功能,因此需要支持库与pre-lollipop设备兼容.您需要将以下内容添加到gradle文件依赖项:
compile 'com.android.support:multidex:1.0.0'
第2步:
还可以在gradle文件中启用multidex输出:
android {
compileSdkVersion 21
buildToolsVersion "21.1.0"
defaultConfig {
...
minSdkVersion 14
targetSdkVersion 21
...
// Enabling multidex support.
multiDexEnabled true
}
}
第3步:
然后将multidex支持应用程序添加到清单中:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.android.multidex.myapplication">
<application
...
android:name="android.support.multidex.MultiDexApplication">
...
</application>
注意:如果您的应用程序已经使用(扩展)Application类,则可以覆盖attachBaseContext()方法并调用MultiDex.install(this)以启用multidex.有关更多信息,请参阅MultiDexApplication参考文档.
@Override
protected void attachBaseContext(Context context) {
super.attachBaseContext(context);
MultiDex.install(this);
}
以下是相同的参考说明:https://developer.android.com/tools/building/multidex.html