Reputation: 132
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)
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()
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'
Any ideas or is my only soultion to bump up minimum supported API?
Upvotes: 0
Views: 1534
Reputation: 38319
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
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.
Because Firebase requires Google Play services, it's good practice to confirm that it is available using GoogleApiAvailability as explained in the documentation.
Upvotes: 6