我正在按照本教程https://www.codementor.io/ememobongakpanekpo/guide-to-firebase-phone-authentication-in-android-using-kotlin-fxq3o83l1来登录Firebase。
我添加了最新的依赖项
Build.gradle.app
implementation 'com.google.firebase:firebase-core:16.0.1'
implementation 'com.google.firebase:firebase-auth:16.0.2'
implementation 'com.firebaseui:firebase-ui-auth:3.1.3'
Build.gradle.project
classpath 'com.google.gms:google-services:4.0.1'
当尝试登录时......
private fun signIn(){
val params = Bundle()
params.putString(AuthUI.EXTRA_DEFAULT_COUNTRY_CODE, "ng")
params.putString(AuthUI.EXTRA_DEFAULT_NATIONAL_NUMBER, "23456789")
val phoneConfigWithDefaultNumber = AuthUI.IdpConfig.Builder(AuthUI.PHONE_VERIFICATION_PROVIDER)
.setParams(params)
.build()
startActivityForResult(
AuthUI.getInstance()
.createSignInIntentBuilder()
.setAvailableProviders(
Arrays.asList(phoneConfigWithDefaultNumber))
.build(),
RC_SIGN_IN)
}
我收到以下错误
java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/android/gms/common/api/Api$zzf;
at com.google.android.gms.auth.api.Auth.<clinit>(Unknown Source)
at com.firebase.ui.auth.util.signincontainer.SignInDelegate.onCreate(SignInDelegate.java:102)
at android.support.v4.app.Fragment.performCreate(Fragment.java:2246)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1377)
at android.support.v4.app.FragmentManagerImpl.moveFragmentToExpectedState(FragmentManager.java:1750)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1819)
at android.support.v4.app.BackStackRecord.executeOps(BackStackRecord.java:797)
at android.support.v4.app.FragmentManagerImpl.executeOps(FragmentManager.java:2590)
at android.support.v4.app.FragmentManagerImpl.executeOpsTogether(FragmentManager.java:2377)
at android.support.v4.app.FragmentManagerImpl.removeRedundantOperationsAndExecute(FragmentManager.java:2332)
at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:2239)
at android.support.v4.app.FragmentManagerImpl.dispatchStateChange(FragmentManager.java:3231)
at android.support.v4.app.FragmentManagerImpl.dispatchActivityCreated(FragmentManager.java:3181)
at android.support.v4.app.FragmentController.dispatchActivityCreated(FragmentController.java:192)
at android.support.v4.app.FragmentActivity.onStart(FragmentActivity.java:572)
at android.support.v7.app.AppCompatActivity.onStart(AppCompatActivity.java:177)
at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1254)
at android.app.Activity.performStart(Activity.java:6935)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2756)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2864)
at android.app.ActivityThread.-wrap12(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1567)
at android.os.Handler.dispatchMessage(Handler.java:105)
at android.os.Looper.loop(Looper.java:156)
at android.app.ActivityThread.main(ActivityThread.java:6523)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:942)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:832)
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.android.gms.common.api.Api$zzf" on path: DexPathList[[zip file "/data/app/com.argandevteam.pranked-1/base.apk", zip file "/data/app/com.argandevteam.pranked-1/split_lib_dependencies_apk.apk", zip file "/data/app/com.argandevteam.pranked-1/split_lib_slice_0_apk.apk", zip file "/data/app/com.argandevteam.pranked-1/split_lib_slice_1_apk.apk", zip file "/data/app/com.argandevteam.pranked-1/split_lib_slice_2_apk.apk", zip file "/data/app/com.argandevteam.pranked-1/split_lib_slice_3_apk.apk", zip file "/data/app/com.argandevteam.pranked-1/split_lib_slice_4_apk.apk", zip file "/data/app/com.argandevteam.pranked-1/split_lib_slice_5_apk.apk", zip file "/data/app/com.argandevteam.pranked-1/split_lib_slice_6_apk.apk", zip file "/data/app/com.argandevteam.pranked-1/split_lib_slice_7_apk.apk", zip file "/data/app/com.argandevteam.pranked-1/split_lib_slice_8_apk.apk", zip file "/data/app/com.argandevteam.pranked-1/split_lib_slice_9_apk.apk"],nativeLibraryDirectories=[/data/app/com.argandevteam.pranked-1/lib/arm64, /system/lib64, /vendor/lib64, /system/vendor/lib64, /product/lib64]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
at java.lang.ClassLoader.loadClass(ClassLoader.java:380)
答案 0 :(得分:2)
更新以下行为:
implementation 'com.firebaseui:firebase-ui-auth:3.1.3'
对此:
implementation 'com.firebaseui:firebase-ui-auth:4.0.1'
FirebaseUI应该与firebase库兼容。
查看下面的链接以获取更多信息: