拒绝先前失败的类com.google.android.gms.location.LocationService的重新初始化

时间:2017-06-12 15:10:21

标签: android gradle google-play-services

我运行这行代码时遇到错误:

 mGoogleApiClient = new GoogleApiClient.Builder(this)
            .addConnectionCallbacks(this)
            .addOnConnectionFailedListener(this)
            .addApi(LocationServices.API)
            .build();

我认为错误是由ProGuard中的一些错误配置引起的,但我无法弄清楚是什么。 Fyi,multidex已启用。

如果重要,我的应用会使用Firebase。

该应用运行良好,但只有在使用mGoogleApiClient启动活动时才会崩溃。

错误是:

06-12 16:58:33.620 24826-24826/com.glennruysschaert.arbitrium I/art: Rejecting re-init on previously-failed class java.lang.Class<com.google.android.gms.location.LocationServices$zza>: java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/android/gms/internal/zzzv$zza;
06-12 16:58:33.620 24826-24826/com.glennruysschaert.arbitrium I/art:     at void com.google.android.gms.location.LocationServices.<clinit>() ((null):-1)
06-12 16:58:33.620 24826-24826/com.glennruysschaert.arbitrium I/art:     at void com.glennruysschaert.arbitrium.Foursquare.FoursquarePlacePickerActivity.onCreate(android.os.Bundle) (FoursquarePlacePickerActivity.java:81)
06-12 16:58:33.620 24826-24826/com.glennruysschaert.arbitrium I/art:     at void android.app.Activity.performCreate(android.os.Bundle) (Activity.java:6760)
06-12 16:58:33.620 24826-24826/com.glennruysschaert.arbitrium I/art:     at void android.app.Instrumentation.callActivityOnCreate(android.app.Activity, android.os.Bundle) (Instrumentation.java:1134)
06-12 16:58:33.620 24826-24826/com.glennruysschaert.arbitrium I/art:     at android.app.Activity android.app.ActivityThread.performLaunchActivity(android.app.ActivityThread$ActivityClientRecord, android.content.Intent) (ActivityThread.java:2681)
06-12 16:58:33.620 24826-24826/com.glennruysschaert.arbitrium I/art:     at void android.app.ActivityThread.handleLaunchActivity(android.app.ActivityThread$ActivityClientRecord, android.content.Intent, java.lang.String) (ActivityThread.java:2814)
06-12 16:58:33.620 24826-24826/com.glennruysschaert.arbitrium I/art:     at void android.app.ActivityThread.-wrap12(android.app.ActivityThread, android.app.ActivityThread$ActivityClientRecord, android.content.Intent, java.lang.String) (ActivityThread.java:-1)
06-12 16:58:33.620 24826-24826/com.glennruysschaert.arbitrium I/art:     at void android.app.ActivityThread$H.handleMessage(android.os.Message) (ActivityThread.java:1527)
06-12 16:58:33.620 24826-24826/com.glennruysschaert.arbitrium I/art:     at void android.os.Handler.dispatchMessage(android.os.Message) (Handler.java:102)
06-12 16:58:33.620 24826-24826/com.glennruysschaert.arbitrium I/art:     at void android.os.Looper.loop() (Looper.java:154)
06-12 16:58:33.620 24826-24826/com.glennruysschaert.arbitrium I/art:     at void android.app.ActivityThread.main(java.lang.String[]) (ActivityThread.java:6290)
06-12 16:58:33.620 24826-24826/com.glennruysschaert.arbitrium I/art:     at java.lang.Object java.lang.reflect.Method.invoke!(java.lang.Object, java.lang.Object[]) (Method.java:-2)
06-12 16:58:33.620 24826-24826/com.glennruysschaert.arbitrium I/art:     at void com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run() (ZygoteInit.java:886)
06-12 16:58:33.620 24826-24826/com.glennruysschaert.arbitrium I/art:     at void com.android.internal.os.ZygoteInit.main(java.lang.String[]) (ZygoteInit.java:776)
06-12 16:58:33.620 24826-24826/com.glennruysschaert.arbitrium I/art: Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.android.gms.internal.zzzv$zza" on path: DexPathList[[zip file "/data/app/com.glennruysschaert.arbitrium-2/base.apk"],nativeLibraryDirectories=[/data/app/com.glennruysschaert.arbitrium-2/lib/arm64, /system/lib64, /vendor/lib64]]
06-12 16:58:33.620 24826-24826/com.glennruysschaert.arbitrium I/art:     at java.lang.Class dalvik.system.BaseDexClassLoader.findClass(java.lang.String) (BaseDexClassLoader.java:56)
06-12 16:58:33.620 24826-24826/com.glennruysschaert.arbitrium I/art:     at java.lang.Class java.lang.ClassLoader.loadClass(java.lang.String, boolean) (ClassLoader.java:380)
06-12 16:58:33.620 24826-24826/com.glennruysschaert.arbitrium I/art:     at java.lang.Class java.lang.ClassLoader.loadClass(java.lang.String) (ClassLoader.java:312)
06-12 16:58:33.620 24826-24826/com.glennruysschaert.arbitrium I/art:     at void com.google.android.gms.location.LocationServices.<clinit>() ((null):-1)
06-12 16:58:33.620 24826-24826/com.glennruysschaert.arbitrium I/art:     at void com.glennruysschaert.arbitrium.Foursquare.FoursquarePlacePickerActivity.onCreate(android.os.Bundle) (FoursquarePlacePickerActivity.java:81)
06-12 16:58:33.620 24826-24826/com.glennruysschaert.arbitrium I/art:     at void android.app.Activity.performCreate(android.os.Bundle) (Activity.java:6760)
06-12 16:58:33.620 24826-24826/com.glennruysschaert.arbitrium I/art:     at void android.app.Instrumentation.callActivityOnCreate(android.app.Activity, android.os.Bundle) (Instrumentation.java:1134)
06-12 16:58:33.620 24826-24826/com.glennruysschaert.arbitrium I/art:     at android.app.Activity android.app.ActivityThread.performLaunchActivity(android.app.ActivityThread$ActivityClientRecord, android.content.Intent) (ActivityThread.java:2681)
06-12 16:58:33.620 24826-24826/com.glennruysschaert.arbitrium I/art:     at void android.app.ActivityThread.handleLaunchActivity(android.app.ActivityThread$ActivityClientRecord, android.content.Intent, java.lang.String) (ActivityThread.java:2814)
06-12 16:58:33.620 24826-24826/com.glennruysschaert.arbitrium I/art:     at void android.app.ActivityThread.-wrap12(android.app.ActivityThread, android.app.ActivityThread$ActivityClientRecord, android.content.Intent, java.lang.String) (ActivityThread.java:-1)
06-12 16:58:33.620 24826-24826/com.glennruysschaert.arbitrium I/art:     at void android.app.ActivityThread$H.handleMessage(android.os.Message) (ActivityThread.java:1527)
06-12 16:58:33.620 24826-24826/com.glennruysschaert.arbitrium I/art:     at void android.os.Handler.dispatchMessage(android.os.Message) (Handler.java:102)
06-12 16:58:33.620 24826-24826/com.glennruysschaert.arbitrium I/art:     at void android.os.Looper.loop() (Looper.java:154)
06-12 16:58:33.620 24826-24826/com.glennruysschaert.arbitrium I/art:     at void android.app.ActivityThread.main(java.lang.String[]) (ActivityThread.java:6290)
06-12 16:58:33.620 24826-24826/com.glennruysschaert.arbitrium I/art:     at java.lang.Object java.lang.reflect.Method.invoke!(java.lang.Object, java.lang.Object[]) (Method.java:-2)
06-12 16:58:33.620 24826-24826/com.glennruysschaert.arbitrium I/art:     at void com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run() (ZygoteInit.java:886)
06-12 16:58:33.620 24826-24826/com.glennruysschaert.arbitrium I/art:     at void com.android.internal.os.ZygoteInit.main(java.lang.String[]) (ZygoteInit.java:776)
06-12 16:58:33.621 24826-24826/com.glennruysschaert.arbitrium I/art: Rejecting re-init on previously-failed class java.lang.Class<com.google.android.gms.internal.zzarl$zza>: java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/android/gms/location/LocationServices$zza;
06-12 16:58:33.621 24826-24826/com.glennruysschaert.arbitrium I/art:     at void com.google.android.gms.location.LocationServices.<clinit>() ((null):-1)
06-12 16:58:33.621 24826-24826/com.glennruysschaert.arbitrium I/art:     at void com.glennruysschaert.arbitrium.Foursquare.FoursquarePlacePickerActivity.onCreate(android.os.Bundle) (FoursquarePlacePickerActivity.java:81)
06-12 16:58:33.621 24826-24826/com.glennruysschaert.arbitrium I/art:     at void android.app.Activity.performCreate(android.os.Bundle) (Activity.java:6760)
06-12 16:58:33.621 24826-24826/com.glennruysschaert.arbitrium I/art:     at void android.app.Instrumentation.callActivityOnCreate(android.app.Activity, android.os.Bundle) (Instrumentation.java:1134)
06-12 16:58:33.621 24826-24826/com.glennruysschaert.arbitrium I/art:     at android.app.Activity android.app.ActivityThread.performLaunchActivity(android.app.ActivityThread$ActivityClientRecord, android.content.Intent) (ActivityThread.java:2681)
06-12 16:58:33.621 24826-24826/com.glennruysschaert.arbitrium I/art:     at void android.app.ActivityThread.handleLaunchActivity(android.app.ActivityThread$ActivityClientRecord, android.content.Intent, java.lang.String) (ActivityThread.java:2814)
06-12 16:58:33.621 24826-24826/com.glennruysschaert.arbitrium I/art:     at void android.app.ActivityThread.-wrap12(android.app.ActivityThread, android.app.ActivityThread$ActivityClientRecord, android.content.Intent, java.lang.String) (ActivityThread.java:-1)
06-12 16:58:33.621 24826-24826/com.glennruysschaert.arbitrium I/art:     at void android.app.ActivityThread$H.handleMessage(android.os.Message) (ActivityThread.java:1527)
06-12 16:58:33.621 24826-24826/com.glennruysschaert.arbitrium I/art:     at void android.os.Handler.dispatchMessage(android.os.Message) (Handler.java:102)
06-12 16:58:33.621 24826-24826/com.glennruysschaert.arbitrium I/art:     at void android.os.Looper.loop() (Looper.java:154)
06-12 16:58:33.621 24826-24826/com.glennruysschaert.arbitrium I/art:     at void android.app.ActivityThread.main(java.lang.String[]) (ActivityThread.java:6290)
06-12 16:58:33.621 24826-24826/com.glennruysschaert.arbitrium I/art:     at java.lang.Object java.lang.reflect.Method.invoke!(java.lang.Object, java.lang.Object[]) (Method.java:-2)
06-12 16:58:33.621 24826-24826/com.glennruysschaert.arbitrium I/art:     at void com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run() (ZygoteInit.java:886)
06-12 16:58:33.621 24826-24826/com.glennruysschaert.arbitrium I/art:     at void com.android.internal.os.ZygoteInit.main(java.lang.String[]) (ZygoteInit.java:776)
06-12 16:58:33.621 24826-24826/com.glennruysschaert.arbitrium I/art: Caused by: java.lang.ClassNotFoundException: com.google.android.gms.location.LocationServices$zza
06-12 16:58:33.621 24826-24826/com.glennruysschaert.arbitrium I/art:     at java.lang.Class java.lang.VMClassLoader.findLoadedClass!(java.lang.ClassLoader, java.lang.String) (VMClassLoader.java:-2)
06-12 16:58:33.621 24826-24826/com.glennruysschaert.arbitrium I/art:     at java.lang.Class java.lang.ClassLoader.findLoadedClass(java.lang.String) (ClassLoader.java:742)
06-12 16:58:33.621 24826-24826/com.glennruysschaert.arbitrium I/art:     at java.lang.Class java.lang.ClassLoader.loadClass(java.lang.String, boolean) (ClassLoader.java:362)
06-12 16:58:33.621 24826-24826/com.glennruysschaert.arbitrium I/art:     at java.lang.Class java.lang.ClassLoader.loadClass(java.lang.String) (ClassLoader.java:312)
06-12 16:58:33.621 24826-24826/com.glennruysschaert.arbitrium I/art:     at void com.google.android.gms.location.LocationServices.<clinit>() ((null):-1)

我的ProGuard文件:

-keep public class * implements com.bumptech.glide.module.GlideModule
-keep public enum com.bumptech.glide.load.resource.bitmap.ImageHeaderParser$** {
  **[] $VALUES;
  public *;
}

-dontwarn okio.**
-dontwarn javax.annotation.**

-keep class com.google.android.gms.** { *; }
-dontwarn com.google.android.gms.**

Gradle文件:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 24
    buildToolsVersion "25.0.0"
    defaultConfig {
        applicationId "MYAPPID..."
        minSdkVersion 19
        targetSdkVersion 24
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        multiDexEnabled  true
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

repositories {
    mavenCentral()
    flatDir {
        dirs 'libs'
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    compile 'com.android.support:appcompat-v7:24.2.1'
    compile 'com.android.support.constraint:constraint-layout:1.0.0-alpha9'
    compile fileTree(include: ['*.jar'], dir: 'libs')

    //Firebase
    compile 'com.google.firebase:firebase-core:10.0.1'
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:design:24.0.0'
    compile 'com.firebaseui:firebase-ui:1.2.0'
    compile 'com.google.firebase:firebase-analytics:9.2.0'

    //Circle Image
    compile 'de.hdodenhof:circleimageview:2.1.0'

    //Glide - Offline image store library
    compile 'com.github.bumptech.glide:glide:4.0.0-RC0'
    annotationProcessor 'com.github.bumptech.glide:compiler:4.0.0-RC0'

    //Info dialog: https://github.com/yarolegovich/LovelyDialog
    compile 'com.yarolegovich:lovely-dialog:1.0.7'

    //Calendar like transition between activities: compile 'com.kogitune:pre-lollipop-activity-transition:1.x.x'
    compile 'com.kogitune:pre-lollipop-activity-transition:1.3.3'


    //Control animations: https://github.com/andkulikov/transitions-everywhere
    compile "com.andkulikov:transitionseverywhere:1.7.4"

    //Http requests: https://github.com/square/retrofit

    //Play services
    //compile 'com.google.android.gms:play-services:10.0.1'
    compile 'com.google.android.gms:play-services-maps:10.0.1'
    compile 'com.google.android.gms:play-services-location:10.0.1'

    //Multidex
    compile 'com.android.support:multidex:1.0.1'
}


apply plugin: 'com.google.gms.google-services'

libs文件夹仅包含:retrofit-2.3.0.jar

1 个答案:

答案 0 :(得分:0)

我明白了。我似乎是因为Google Play服务版本存在冲突。

我使用以下命令检查Firebase的Play服务依赖项:

gradle app:dependencies

这表明Firebase使用的是旧版本。 因此,我将Firebase版本设置为11.0.0并删除了“firebase-analytics”。然后我还将地图和位置版本设置为11.0.0并使用命令再次检查依赖项。

现在,Google Play服务的所有依赖关系都是相同的。现在该应用运行良好。