signOut方法(来自Firebase身份验证)停止我的应用

时间:2017-10-22 18:05:00

标签: android firebase-authentication

我将Firebase身份验证添加到我的应用中。我没有问题地构建APK。我在模拟器上运行应用程序,当我按下signOut按钮时,应用程序停止工作。 调试器显示:

10-22 17:56:30.246 2540-2540/com.doov.prototype E/AndroidRuntime: FATAL EXCEPTION: main
                                                                  Process: com.doov.prototype, PID: 2540
                                                                  java.lang.IncompatibleClassChangeError: Superclass com.google.android.gms.internal.zzbax of com.google.android.gms.internal.zzarm is an interface (declaration of 'com.google.android.gms.internal.zzarm' appears in /data/app/com.doov.prototype-EkSA0Y-MCxsGwYGtmSxRQQ==/split_lib_dependencies_apk.apk:classes33.dex)
                                                                      at com.google.android.gms.auth.api.Auth.<clinit>(Unknown Source:95)
                                                                      at com.firebase.ui.auth.util.GoogleSignInHelper.getInstance(GoogleSignInHelper.java:21)
                                                                      at com.firebase.ui.auth.AuthUI.signOut(AuthUI.java:175)
                                                                      at com.doov.prototype.SignedInActivity.signOut(SignedInActivity.java:38)
                                                                      at java.lang.reflect.Method.invoke(Native Method)
                                                                      at android.support.v7.app.AppCompatViewInflater$DeclaredOnClickListener.onClick(AppCompatViewInflater.java:288)
                                                                      at android.view.View.performClick(View.java:6256)
                                                                      at android.view.View$PerformClick.run(View.java:24701)
                                                                      at android.os.Handler.handleCallback(Handler.java:789)
                                                                      at android.os.Handler.dispatchMessage(Handler.java:98)
                                                                      at android.os.Looper.loop(Looper.java:164)
                                                                      at android.app.ActivityThread.main(ActivityThread.java:6541)
                                                                      at java.lang.reflect.Method.invoke(Native Method)
                                                                      at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
                                                                      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)
10-22 17:56:30.251 2540-2540/com.doov.prototype E/UncaughtException: java.lang.IncompatibleClassChangeError: Superclass com.google.android.gms.internal.zzbax of com.google.android.gms.internal.zzarm is an interface (declaration of 'com.google.android.gms.internal.zzarm' appears in /data/app/com.doov.prototype-EkSA0Y-MCxsGwYGtmSxRQQ==/split_lib_dependencies_apk.apk:classes33.dex)
                                                                         at com.google.android.gms.auth.api.Auth.<clinit>(Unknown Source:95)
                                                                         at com.firebase.ui.auth.util.GoogleSignInHelper.getInstance(GoogleSignInHelper.java:21)
                                                                         at com.firebase.ui.auth.AuthUI.signOut(AuthUI.java:175)
                                                                         at com.doov.prototype.SignedInActivity.signOut(SignedInActivity.java:38)
                                                                         at java.lang.reflect.Method.invoke(Native Method)
                                                                         at android.support.v7.app.AppCompatViewInflater$DeclaredOnClickListener.onClick(AppCompatViewInflater.java:288)
                                                                         at android.view.View.performClick(View.java:6256)
                                                                         at android.view.View$PerformClick.run(View.java:24701)
                                                                         at android.os.Handler.handleCallback(Handler.java:789)
                                                                         at android.os.Handler.dispatchMessage(Handler.java:98)
                                                                         at android.os.Looper.loop(Looper.java:164)
                                                                         at android.app.ActivityThread.main(ActivityThread.java:6541)
                                                                         at java.lang.reflect.Method.invoke(Native Method)
                                                                         at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
                                                                         at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)

我是编程新手,所以我不清楚如何调试。有小费吗?提前谢谢。

以下是build.gradle依赖项:

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.3.3'
        classpath 'com.google.gms:google-services:3.0.0'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}
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:25.3.1'
    compile 'com.android.support.constraint:constraint-layout:1.0.2'
    compile 'com.google.firebase:firebase-auth:11.0.4'
    compile 'com.firebaseui:firebase-ui:2.0.1'
    compile 'com.firebaseui:firebase-ui-auth:2.0.1'
    compile 'com.google.android.gms:play-services-maps:11.0.4'
    compile 'com.google.firebase:firebase-database:10.0.1'
    testCompile 'junit:junit:4.12'
}

1 个答案:

答案 0 :(得分:0)

根据:

https://github.com/firebase/FirebaseUI-Android/issues/798

看起来你错过了依赖。请添加com.google.android.gms:play-services-auth,因为Firebase的身份验证系统需要它。

所以,简而言之,请在build.gradle

中添加此行
compile "com.google.android.gms:play-services-auth:11.0.4"

同时检查其他依赖项的值,并根据这些版本使它们适合:

https://github.com/firebase/FirebaseUI-Android#upgrading-dependencies

Google使用它来模糊他们的库,如果您的依赖项版本不匹配,这会导致问题。