使用Firebase Auth 认证的时候出现如下错误:
1612145598.686 21721-21721/com.change.demox E/om.change.demo: Invalid ID 0x00000000.
1612145621.043 21721-21721/com.change.demox E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.change.demox, PID: 21721
java.lang.NoClassDefFoundError: Failed resolution of: Landroidx/browser/customtabs/CustomTabsIntent$Builder;
at com.google.firebase.auth.internal.GenericIdpActivity.zza(com.google.firebase:firebase-auth@@20.0.1:13)
at com.google.android.gms.internal.firebase-auth-api.zzth.zzb(com.google.firebase:firebase-auth@@20.0.1:7)
at com.google.android.gms.internal.firebase-auth-api.zzth.onPostExecute(Unknown Source:2)
at android.os.AsyncTask.finish(AsyncTask.java:771)
at android.os.AsyncTask.access$900(AsyncTask.java:199)
at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:788)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:223)
at android.app.ActivityThread.main(ActivityThread.java:7660)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)
Caused by: java.lang.ClassNotFoundException: Didn't find class "androidx.browser.customtabs.CustomTabsIntent$Builder" on path: DexPathList[[zip file "/data/app/~~pLum11JxTpmol9LYyROAYA==/com.change.demox-6Bxjfxrp6KlmX5AqSTYTWg==/base.apk"],nativeLibraryDirectories=[/data/app/~~pLum11JxTpmol9LYyROAYA==/com.change.demox-6Bxjfxrp6KlmX5AqSTYTWg==/lib/arm64, /data/app/~~pLum11JxTpmol9LYyROAYA==/com.change.demox-6Bxjfxrp6KlmX5AqSTYTWg==/base.apk!/lib/arm64-v8a, /system/lib64, /system_ext/lib64]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:207)
at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
at com.google.firebase.auth.internal.GenericIdpActivity.zza(com.google.firebase:firebase-auth@@20.0.1:13)
at com.google.android.gms.internal.firebase-auth-api.zzth.zzb(com.google.firebase:firebase-auth@@20.0.1:7)
at com.google.android.gms.internal.firebase-auth-api.zzth.onPostExecute(Unknown Source:2)
at android.os.AsyncTask.finish(AsyncTask.java:771)
at android.os.AsyncTask.access$900(AsyncTask.java:199)
at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:788)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:223)
at android.app.ActivityThread.main(ActivityThread.java:7660)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)
网上搜到的主流解法是似乎auth未添加用于reCAPTCH验证的浏览器,因此在Android上导致崩溃,引入依赖:implementation "androidx.browser:browser:1.2.0" 。但是这种解法在我的项目依然不好用。最后尝试出如果项目用的是compileSdkVersion 29 ,那么需要降低Auth依赖的版本至implementation 'com.google.firebase:firebase-auth-ktx:19.3.1',降低到20以下就能解决,20以上的Auth包必须搭配30以上的SDK版本才不会发生崩溃。