KitKat上的Android Firebase Auth崩溃 [英] Android Firebase Auth Crash on KitKat

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

问题描述

我使用Firebase匿名身份验证的应用在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 Auth崩溃从调用FirebaseAuth.signInAnonymously()到调用NullPointerException的API 15和16

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 Auth崩溃的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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