gpt4 book ai didi

android - Firebase 电话身份验证在 android 中无法使用 20.0.0 版

转载 作者:行者123 更新时间:2023-12-03 20:24:08 25 4
gpt4 key购买 nike

我确实根据 this doc 将 firebase 依赖项更新为最新版本
旧依赖项

 implementation 'com.google.firebase:firebase-core:17.5.1'
implementation 'com.google.firebase:firebase-analytics:17.6.0'
implementation 'com.google.firebase:firebase-crashlytics:17.2.2'
implementation 'com.google.firebase:firebase-auth:19.4.0'
implementation 'com.google.firebase:firebase-firestore-ktx:21.7.1'
更新的依赖项
   //firebase
//By using the Firebase Android BoM, your app will always use compatible versions of the Firebase Android libraries.
implementation platform('com.google.firebase:firebase-bom:26.0.0')
// When using the BoM, you don't specify versions in Firebase library dependencies
implementation 'com.google.firebase:firebase-analytics-ktx'
implementation 'com.google.firebase:firebase-auth-ktx'
implementation 'com.google.firebase:firebase-firestore-ktx'
//The Firebase Authentication Android library now works on devices without Google Play services.
// implementation "com.google.android.gms:play-services-base:17.5.0"
旧手机身份验证方法工作正常
   PhoneAuthProvider.getInstance().verifyPhoneNumber(
number,
60,
TimeUnit.SECONDS,
activity,
this
)
但是,在更新了上述方法的依赖项后显示 deprecated.so,尝试了这个
         val auth = FirebaseAuth.getInstance()
binding.fab.setOnClickListener {
val options = PhoneAuthOptions.newBuilder(auth)
.setPhoneNumber("+1 5123456788")
.setTimeout(60L, TimeUnit.SECONDS)
.setActivity(this)
.build()
PhoneAuthProvider.verifyPhoneNumber(options);
}

调用 build 方法时会发生此错误。
2020-10-29 16:14:57.406 3422-3422/com.gowtham.firebasephoneauthwithmvvm E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.gowtham.firebasephoneauthwithmvvm, PID: 3422
java.lang.NullPointerException: null reference
at com.google.android.gms.common.internal.Preconditions.checkNotNull(com.google.android.gms:play-services-basement@@17.1.0:2)
at com.google.firebase.auth.PhoneAuthOptions$Builder.build(com.google.firebase:firebase-auth@@20.0.0:22)
at com.gowtham.firebasephoneauthwithmvvm.MainActivity$onPostCreate$2.onClick(MainActivity.kt:50)
at android.view.View.performClick(View.java:7861)
at android.view.View.performClickInternal(View.java:7830)
at android.view.View.access$3600(View.java:878)
at android.view.View$PerformClick.run(View.java:29354)
at android.os.Handler.handleCallback(Handler.java:883)
at android.os.Handler.dispatchMessage(Handler.java:100)
at android.os.Looper.loop(Looper.java:237)
at android.app.ActivityThread.main(ActivityThread.java:8107)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:496)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1100)
2020-10-29 16:14:57.428 3422-3422/com.gowtham.firebasephoneauthwithmvvm I/Process: Sending signal.

添加回调后发生此错误
2020-10-30 10:47:34.239 24898-24898/com.gowtham.firebasephoneauthwithmvvm E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.gowtham.firebasephoneauthwithmvvm, PID: 24898
java.lang.NoClassDefFoundError: Failed resolution of: Landroidx/browser/customtabs/CustomTabsIntent$Builder;
at com.google.firebase.auth.internal.RecaptchaActivity.zza(com.google.firebase:firebase-auth@@20.0.0:92)
at com.google.firebase.auth.api.internal.zzeq.zza(com.google.firebase:firebase-auth@@20.0.0:79)
at com.google.firebase.auth.api.internal.zzeq.onPostExecute(com.google.firebase:firebase-auth@@20.0.0:88)
at android.os.AsyncTask.finish(AsyncTask.java:755)
at android.os.AsyncTask.access$900(AsyncTask.java:192)
at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:772)
at android.os.Handler.dispatchMessage(Handler.java:107)
at android.os.Looper.loop(Looper.java:237)
at android.app.ActivityThread.main(ActivityThread.java:8107)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:496)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1100)
Caused by: java.lang.ClassNotFoundException: Didn't find class "androidx.browser.customtabs.CustomTabsIntent$Builder" on path: DexPathList[[zip file "/data/app/com.gowtham.firebasephoneauthwithmvvm-Cn_en1RDZ9XDneMCJamrPw==/base.apk"],nativeLibraryDirectories=[/data/app/com.gowtham.firebasephoneauthwithmvvm-Cn_en1RDZ9XDneMCJamrPw==/lib/arm64, /system/lib64, /product/lib64]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:196)
at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
at com.google.firebase.auth.internal.RecaptchaActivity.zza(com.google.firebase:firebase-auth@@20.0.0:92) 
at com.google.firebase.auth.api.internal.zzeq.zza(com.google.firebase:firebase-auth@@20.0.0:79) 
at com.google.firebase.auth.api.internal.zzeq.onPostExecute(com.google.firebase:firebase-auth@@20.0.0:88) 
at android.os.AsyncTask.finish(AsyncTask.java:755) 
at android.os.AsyncTask.access$900(AsyncTask.java:192) 
at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:772) 
at android.os.Handler.dispatchMessage(Handler.java:107) 
at android.os.Looper.loop(Looper.java:237) 
at android.app.ActivityThread.main(ActivityThread.java:8107) 
at java.lang.reflect.Method.invoke(Native Method) 
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:496) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1100) 
2020-10-30 10:47:34.314 24898-24898/com.gowtham.firebasephoneauthwithmvvm I/Process: Sending signal. PID: 24898 SIG: 9

最佳答案

根据 Firebase 电话验证 documentation ,您需要启用 reCAPTCHA 验证
首先添加 implementation 'androidx.browser:browser:1.3.0'在 build.gradle (module app) 依赖
这将使 firebase 打开浏览器进行 reCAPTCHA 验证。

关于android - Firebase 电话身份验证在 android 中无法使用 20.0.0 版,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64585358/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com