如何解决NoClassDefoundError:Lcom/google/android/gms/auth/api/signin/internal/zzz的问题?

内容来源于 Stack Overflow,并遵循CC BY-SA 3.0许可协议进行翻译与使用

  • 回答 (1)
  • 关注 (0)
  • 查看 (716)

以下是我的代码

protected void onResume(){
    super.onResume();
    getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_FULLSCREEN);
    sign_in_player();
    Log.d("MainActivity", "State: Resumed");


}
private static void sign_in_player(){

    if(!is_signed_into_play_games()){
        GoogleSignInClient google_sign_in_client = GoogleSignIn.getClient(current_context,GoogleSignInOptions.DEFAULT_GAMES_SIGN_IN);
        google_sign_in_client.silentSignIn();
    }
}
public static boolean is_signed_into_play_games(){
    return GoogleSignIn.getLastSignedInAccount(current_context)!= null;
}

build.gradle依赖关系:

dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', {
    exclude group: 'com.android.support', module: 'support-annotations'
})
    implementation 'com.google.android.gms:play-services-identity:15.0.1'
    implementation 'com.google.android.gms:play-services-games:15.0.1'
    implementation 'com.google.android.gms:play-services-ads:15.0.0'
    implementation 'com.google.android.gms:play-services-auth:11.6.0'
    implementation "com.android.support:appcompat-v7:27.1.1"
    implementation 'com.android.support.constraint:constraint-layout:1.1.2'
    testImplementation 'junit:junit:4.12'
    implementation 'com.google.android.gms:play-services-games:15.0.1'
}

运行时错误:

E/AndroidRuntime: FATAL EXCEPTION: main
              Process: com.example.koran.myapplication, PID: 3289
              java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/android/gms/auth/api/signin/internal/zzz;
                  at com.google.android.gms.auth.api.signin.internal.zzo.<init>(Unknown Source:3)
                  at com.google.android.gms.auth.api.signin.internal.zzo.zzbq(Unknown Source:9)
                  at com.google.android.gms.auth.api.signin.internal.zzo.zzbp(Unknown Source:7)
                  at com.google.android.gms.auth.api.signin.GoogleSignIn.getLastSignedInAccount(Unknown Source:0)
                  at com.example.koran.myapplication.MainActivity.is_signed_into_play_games(MainActivity.java:139)
                  at com.example.koran.myapplication.MainActivity.sign_in_player(MainActivity.java:255)
                  at com.example.koran.myapplication.MainActivity.onResume(MainActivity.java:248)
                  at android.app.Instrumentation.callActivityOnResume(Instrumentation.java:1361)
                  at android.app.Activity.performResume(Activity.java:7344)
                  at android.app.ActivityThread.performResumeActivity(ActivityThread.java:3763)
                  at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:3828)
                  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3036)
                  at android.app.ActivityThread.-wrap11(Unknown Source:0)
                  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1696)
                  at android.os.Handler.dispatchMessage(Handler.java:105)
                  at android.os.Looper.loop(Looper.java:164)
                  at android.app.ActivityThread.main(ActivityThread.java:6938)
                  at java.lang.reflect.Method.invoke(Native Method)
                  at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:327)
                  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1374)
               Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.android.gms.auth.api.signin.internal.zzz" on path: DexPathList[[zip file "/data/app/com.example.koran.myapplication-UD0LYeGFGYJW8kKIpwYshw==/base.apk", zip file "/data/app/com.example.koran.myapplication-UD0LYeGFGYJW8kKIpwYshw==/split_lib_dependencies_apk.apk", zip file "/data/app/com.example.koran.myapplication-UD0LYeGFGYJW8kKIpwYshw==/split_lib_resources_apk.apk", zip file "/data/app/com.example.koran.myapplication-UD0LYeGFGYJW8kKIpwYshw==/split_lib_slice_0_apk.apk", zip file "/data/app/com.example.koran.myapplication-UD0LYeGFGYJW8kKIpwYshw==/split_lib_slice_1_apk.apk", zip file "/data/app/com.example.koran.myapplication-UD0LYeGFGYJW8kKIpwYshw==/split_lib_slice_2_apk.apk", zip file "/data/app/com.example.koran.myapplication-UD0LYeGFGYJW8kKIpwYshw==/split_lib_slice_3_apk.apk", zip file "/data/app/com.example.koran.myapplication-UD0LYeGFGYJW8kKIpwYshw==/split_lib_slice_4_apk.apk", zip file "/data/app/com.example.koran.myapplication-UD0LYeGFGYJW8kKIpwYshw==/split_lib_slice_5_apk.apk", zip file "/data/app/com.example.koran.myapplication-UD0LYeGFGYJW8kKIpwYshw==/split_lib_slice_6_apk.apk", zip file "/data/app/com.example.koran.myapplication-UD0LYeGFGYJW8kKIpwYshw==/split_lib_slice_7_apk.apk", zip file "/data/app/com.example.koran.myapplication-UD0LYeGFGYJW8kKIpwYshw==/split_lib_slice_8_apk.apk", zip file "/data/app/com.example.koran.myapplication-UD0LYeGFGYJW8kKIpwYshw==/split_lib_slice_9_apk.apk"],nativeLibraryDirectories=[/data/app/com.example.koran.myapplication-UD0LYeGFGYJW8kKIpwYshw==/lib/arm64, /system/lib64, /system/vendor/lib64]]
                  at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:93)
                  at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
                  at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
                  at com.google.android.gms.auth.api.signin.internal.zzo.<init>(Unknown Source:3) 
                  at com.google.android.gms.auth.api.signin.internal.zzo.zzbq(Unknown Source:9) 
                  at com.google.android.gms.auth.api.signin.internal.zzo.zzbp(Unknown Source:7) 
                  at com.google.android.gms.auth.api.signin.GoogleSignIn.getLastSignedInAccount(Unknown Source:0) 
                  at com.example.koran.myapplication.MainActivity.is_signed_into_play_games(MainActivity.java:139) 
                  at com.example.koran.myapplication.MainActivity.sign_in_player(MainActivity.java:255) 
                  at com.example.koran.myapplication.MainActivity.onResume(MainActivity.java:248) 
                  at android.app.Instrumentation.callActivityOnResume(Instrumentation.java:1361) 
                  at android.app.Activity.performResume(Activity.java:7344) 
                  at android.app.ActivityThread.performResumeActivity(ActivityThread.java:3763) 
                  at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:3828) 
                  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3036) 
                  at android.app.ActivityThread.-wrap11(Unknown Source:0) 
                  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1696) 
                  at android.os.Handler.dispatchMessage(Handler.java:105) 
                  at android.os.Looper.loop(Looper.java:164) 
                  at android.app.ActivityThread.main(ActivityThread.java:6938) 
                  at java.lang.reflect.Method.invoke(Native Method) 
                  at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:327) 
                  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1374) 
                Suppressed: java.io.IOException: No original dex files found for dex location (arm64) /data/app/com.example.koran.myapplication-UD0LYeGFGYJW8kKIpwYshw==/split_lib_resources_apk.apk
                  at dalvik.system.DexFile.openDexFileNative(Native Method)
                  at dalvik.system.DexFile.openDexFile(DexFile.java:353)
                  at dalvik.system.DexFile.<init>(DexFile.java:100)
                  at dalvik.system.DexFile.<init>(DexFile.java:74)
                  at dalvik.system.DexPathList.loadDexFile(DexPathList.java:374)
                  at dalvik.system.DexPathList.makeDexElements(DexPathList.java:337)
                  at dalvik.system.DexPathList.<init>(DexPathList.java:157)
                  at dalvik.system.BaseDexClassLoader.<init>(BaseDexClassLoader.java:65)
                  at dalvik.system.PathClassLoader.<init>(PathClassLoader.java:64)
                  at com.android.internal.os.PathClassLoaderFactory.createClassLoader(PathClassLoaderFactory.java:43)
                  at android.app.ApplicationLoaders.getClassLoader(ApplicationLoaders.java:69)
                  at android.app.ApplicationLoaders.getClassLoader(ApplicationLoaders.java:36)
                  at android.app.LoadedApk.createOrUpdateClassLoaderLocked(LoadedApk.java:678)
                  at android.app.LoadedApk.getClassLoader(LoadedApk.java:711)
                  at android.app.LoadedApk.getResources(LoadedApk.java:944)
                  at android.app.ContextImpl.createAppContext(ContextImpl.java:2303)
                  at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5937)
                  at android.app.ActivityThread.-wrap1(Unknown Source:0)
                  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1764)
                        ... 6 more
提问于
用户回答回答于

你使用的是旧版本的auth,与Play服务的其他更新版本不兼容,因此使用以下命令:

implementation 'com.google.android.gms:play-services-auth:15.0.1'

而不是这个

implementation 'com.google.android.gms:play-services-auth:11.6.0' 
implementation 'com.google.android.gms:play-services-ads:15.0.1'
implementation 'com.google.android.gms:play-services-auth:15.0.1'

扫码关注云+社区

领取腾讯云代金券

年度创作总结 领取年终奖励