KitKat 上的 Android Firebase 身份验证崩溃 [英] Android Firebase Auth Crash on KitKat

查看:15
本文介绍了KitKat 上的 Android Firebase 身份验证崩溃的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用 Firebase Anonymous Auth 的应用在 API19 (4.4) 上崩溃了.

my app using Firebase Anonymous Auth is crashing on API19 (4.4).

E/AndroidRuntime: FATAL EXCEPTION: main
          Process: com.author.example, PID: 2191
          java.lang.RuntimeException: Unable to start activity ComponentInfo{com.author.example/com.author.example.MainActivity}: java.lang.NullPointerException
              at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2195)
              at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245)
              at android.app.ActivityThread.access$800(ActivityThread.java:135)
              at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
              at android.os.Handler.dispatchMessage(Handler.java:102)
              at android.os.Looper.loop(Looper.java:136)
              at android.app.ActivityThread.main(ActivityThread.java:5017)
              at java.lang.reflect.Method.invokeNative(Native Method)
              at java.lang.reflect.Method.invoke(Method.java:515)
              at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
              at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
              at dalvik.system.NativeStart.main(Native Method)
           Caused by: java.lang.NullPointerException
              at com.google.android.gms.internal.zzdvv.zzb(Unknown Source)
              at com.google.android.gms.internal.zzdwc.zza(Unknown Source)
              at com.google.firebase.auth.FirebaseAuth.signInAnonymously(Unknown Source)
              at com.author.example.MainActivity.onCreate(MainActivity.java:64)
              at android.app.Activity.performCreate(Activity.java:5231)
              at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
              at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2159)
              at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245) 
              at android.app.ActivityThread.access$800(ActivityThread.java:135) 
              at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196) 
              at android.os.Handler.dispatchMessage(Handler.java:102) 
              at android.os.Looper.loop(Looper.java:136) 
              at android.app.ActivityThread.main(ActivityThread.java:5017) 
              at java.lang.reflect.Method.invokeNative(Native Method) 
              at java.lang.reflect.Method.invoke(Method.java:515) 

已针对 API 15 和 16 报告了相同的问题,但尚未找到解决方案.Firebase 身份验证崩溃API 15 和 16 带有 NullPointerException 调用 FirebaseAuth.signInAnonymously()

Same issue has been reported for API 15 and 16 but no solution has been found. Firebase Auth crashing on API 15 and 16 with NullPointerException from call to FirebaseAuth.signInAnonymously()

以下是相关的 gradle 依赖项:

Here are relevant gradle dependencies:

compile 'com.google.firebase:firebase-database:11.8.0'
compile 'com.google.firebase:firebase-auth:11.8.0'
compile 'com.firebaseui:firebase-ui-database:1.0.1'
compile 'com.android.support:appcompat-v7:27.0.2'
compile 'com.android.support:design:27.0.2'
compile 'com.android.support.constraint:constraint-layout:1.1.0-beta5'
compile('com.crashlytics.sdk.android:crashlytics:2.7.1@aar') {
    transitive = true
}
compile 'com.google.firebase:firebase-core:11.8.0'
compile 'com.google.firebase:firebase-messaging:11.8.0'
compile 'com.google.maps.android:android-maps-utils:0.5'
compile 'com.google.android.gms:play-services-maps:11.8.0'

是否有任何想法或者是我提高最低支持 API 的唯一方法?

Any ideas or is my only soultion to bump up minimum supported API?

推荐答案

您正在测试的设备或模拟器没有安装与 Firebase SDK 11.8.0 兼容的 Google Play 服务版本.在应用程序初始化时,logcat 将包含以下消息:

The device or emulator you are testing with does not have a version of Google Play services installed that is compatible with Firebase SDK 11.8.0. At the time the app initializes the logcat will contain this message:

W/GooglePlayServicesUtil: Google Play services out of date

如果错误发生在真机上,您需要更新设备上的 Google Play 服务.如果错误发生在模拟器上,您需要使用 SDK 管理器下载最新的模拟器图像并选择一个包含 Google API 的图像.

If the error occurs on a real device, you need to update Google Play services on the device. If the error occurs on an emulator, you need to use the SDK manager to download the latest emulator images and pick one the includes Google API.

因为 Firebase 需要 Google Play 服务,所以最好使用 GoogleApiAvailability中所述文档.

Because Firebase requires Google Play services, it's good practice to confirm that it is available using GoogleApiAvailability as explained in the documentation.

这篇关于KitKat 上的 Android Firebase 身份验证崩溃的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆