简体   繁体   English

引起:java.lang.ClassNotFoundException:在 Firebase 电话身份验证中找不到类

[英]Caused by: java.lang.ClassNotFoundException: Didn't find class in Firebase Phone Authentication

I'm using Phone Authentication in Android Studio via Firebase, I Enabled Phone SignIn and Add SHA-1 And SHA-256 in Firebase Project.我通过 Firebase 在 Android Studio 中使用电话身份验证,我启用了电话登录并在 Firebase 项目中添加了 SHA-1 和 SHA-256。 here is all of my dependencies :这是我所有的依赖项:

dependencies {

implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'com.google.android.material:material:1.2.1'
implementation 'androidx.constraintlayout:constraintlayout:2.0.2'
testImplementation 'junit:junit:4.13.1'
implementation 'com.hbb20:ccp:2.4.0'
implementation 'com.google.firebase:firebase-auth:20.0.0'
implementation 'com.google.firebase:firebase-analytics'
implementation platform('com.google.firebase:firebase-bom:26.0.0')
implementation 'com.google.android.gms:play-services-safetynet:17.0.0'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
}

and here is the error logs:这是错误日志:

E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.securechat, PID: 24159
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:695)
    at android.os.AsyncTask.access$600(AsyncTask.java:180)
    at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:712)
    at android.os.Handler.dispatchMessage(Handler.java:106)
    at android.os.Looper.loop(Looper.java:193)
    at android.app.ActivityThread.main(ActivityThread.java:6692)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
 Caused by: java.lang.ClassNotFoundException: Didn't find class "androidx.browser.customtabs.CustomTabsIntent$Builder" on path: DexPathList[[zip file "/data/app/com.example.securechat-GUvvd01g4yeRO2eP4pBFfA==/base.apk"],nativeLibraryDirectories=[/data/app/com.example.securechat-GUvvd01g4yeRO2eP4pBFfA==/lib/arm64, /system/lib64, /vendor/lib64]]
    at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:134)
    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:695) 
    at android.os.AsyncTask.access$600(AsyncTask.java:180) 
    at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:712) 
    at android.os.Handler.dispatchMessage(Handler.java:106) 
    at android.os.Looper.loop(Looper.java:193) 
    at android.app.ActivityThread.main(ActivityThread.java:6692) 
    at java.lang.reflect.Method.invoke(Native Method) 
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493) 
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858) 

implementation androidx.browser:browser:1.2.0实现androidx.browser:browser:1.2.0

Use this dependency to solve the problem.使用这个依赖来解决问题。

In new Firebase auth version,they've made major changes like Recaptcha , SafetyNet for human verification.在新的 Firebase 身份验证版本中,他们进行了重大更改,例如 Recaptcha、SafetyNet 以进行人工验证。 By adding通过添加

implementation "androidx.browser:browser:1.3.0"实现“androidx.browser:browser:1.3.0”

it solved my problem but user experience was not good because firebase was opening browser to verify reCAPTCHA and that was looking odd in app flow.它解决了我的问题,但用户体验并不好,因为 firebase 正在打开浏览器来验证 reCAPTCHA,这在应用程序流程中看起来很奇怪。

Firebase Quote " The reCAPTCHA flow will only be triggered when SafetyNet is unavailable or your device does not pass suspicion checks. Nonetheless, you should ensure that both scenarios are working correctly. " So to enable SafetyNet follow below steps or you can also visit Firebase Auth for more info. Firebase 引用“只有在 SafetyNet 不可用或您的设备未通过可疑检查时才会触发 reCAPTCHA 流程。但是,您应该确保这两种情况都正常工作。 ”因此,要启用 SafetyNet,请按照以下步骤操作,或者您也可以访问Firebase Auth了解更多信息。

  1. Go to google cloud console , select your project .转到谷歌云控制台,选择您的项目。

  2. Click on navigation menu and select APis & services and then select Dashboard .单击导航菜单并选择 APIs & services,然后选择 Dashboard 。

  3. Click on enable api and services and enable api " Android Device Verification".点击启用api和服务并启用api“Android设备验证”。

  4. Add SHA 256 in firebase project settings.(debug and release both)在 firebase 项目设置中添加 SHA 256。(调试并发布两者)

  5. Download and replace the latest google-services.json file in your project.下载并替换项目中最新的 google-services.json 文件。

If someone coming from react-native , after searching all around I found this temporary solution.如果有人来自react-native ,经过四处搜索后,我找到了这个临时解决方案。

Adding the below添加以下内容

implementation "androidx.browser:browser:1.2.0"

into android/app/build.gradle dependencies solved issue.进入android/app/build.gradle依赖项解决了问题。

您需要将 CustomTabs 添加到您的项目中,以便您的移动应用程序可以使用 CustomTabs 访问浏览器

implementation 'com.android.support:customtabs:28.0.0'

Same thing happened with me.同样的事情发生在我身上。 What I did basically removed the following line-我所做的基本上删除了以下行-

implementation platform('com.google.firebase:firebase-bom:26.0.0')

Since you're using the firebase-bom dependency , that library determines the version of all Firebase SDKs you use.由于您使用的是firebase-bom依赖项库决定了您使用的所有 Firebase SDK 的版本。 This means that you should not specify version numbers for any other Firebase SDKs in your gradle file.这意味着您不应在 gradle 文件中为任何其他 Firebase SDK 指定版本号。

So remove the version number from firebase-auth :所以从firebase-auth删除版本号:

implementation 'com.google.firebase:firebase-auth'
implementation 'com.google.firebase:firebase-analytics'
implementation platform('com.google.firebase:firebase-bom:26.0.0')

Follow the below steps:请按照以下步骤操作:

  1. In the Google Cloud console, enable the Android DeviceCheck API for your project.在 Google Cloud 控制台中,为您的项目启用Android DeviceCheck API

  2. Get SHA-256 fingerprint for below frameworks:获取以下框架的 SHA-256 指纹:

  3. Go toSettings Page of the Firebase console, select your project and set the SHA-256 fingerprint for your app.转到 Firebase 控制台的设置页面,选择您的项目并为您的应用设置 SHA-256 指纹。

  4. Re-run the app.重新运行应用程序。

For more info go to Enable app verification doc.有关详细信息,请转到启用应用验证文档。

在您的 build.gradle 文件中添加此依赖项... implementation 'com.android.support:customtabs:28.0.0-alpha3'

Guys I have found a way just follow the steps.伙计们,我找到了一种方法,只需按照步骤操作即可。 In "Phone Authentication docs" of firebase you will find the option (2.Enable app verification) Follow these steps:在firebase的“电话身份验证文档”中,您会找到选项(2.启用应用验证)按照以下步骤操作:

  • Enable AndroidDevice check API by clicking on it.单击以启用 AndroidDevice 检查 API。

  • Then add your SHA-256.然后添加您的 SHA-256。 (Gradle on your right side of android studio->Tasks->android->signingReports. ) android studio->Tasks->android->signingReports.右侧的android studio->Tasks->android->signingReports.

You will get your SHA-256 there for your app.您将在那里为您的应用程序获取 SHA-256。

Just add this line: implementation "androidx.browser:browser:1.3.0"只需添加这一行: implementation "androidx.browser:browser:1.3.0"

It will solve your problem definitely.它肯定会解决您的问题。 Make sure to also add the SHA-256 in Firebase.确保还在 Firebase 中添加 SHA-256。

Add this dependency in your build.gradle file...在您的 build.gradle 文件中添加此依赖项...

implementation platform('com.google.firebase:firebase-bom:26.2.0')

Now, Add your SHA-256 (Gradle on your right side of android studio->Tasks->android->signingReports) in settings of your project.现在,在您的项目设置中添加您的 SHA-256(Android studio->Tasks->android->signingReports 右侧的 Gradle)。

Following steps are very important...以下步骤很重要...

  • Go to Google Cloud and select your project.转到Google Cloud并选择您的项目。
  • Select 'APis & services' from left hand side menu and then select Dashboard.从左侧菜单中选择“API 和服务”,然后选择仪表板。
  • Click on 'Enable api and services' and then enable api 'Android Device Verification'.单击“启用 api 和服务”,然后启用 api“Android 设备验证”。

在此处输入图片说明

In this click on 'VIEW ALL to get 'Android Device Verification' tab.在此单击“查看全部”以获取“Android 设备验证”选项卡。

You can't test on an emulator, are you using a real phone?你不能在模拟器上测试,你用的是真手机吗? If you want to test from an emulator check this out https://firebase.flutter.dev/docs/auth/phone/#testing如果您想从模拟器进行测试,请查看https://firebase.flutter.dev/docs/auth/phone/#testing

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 原因:java.lang.ClassNotFoundException:在路径上找不到类 - Caused by: java.lang.ClassNotFoundException: Didn't find class on path 由java.lang.ClassNotFoundException引起找不到类“ com.google.android.gms.measurement.AppMeasurementInstallReferrerReceiver - Caused by java.lang.ClassNotFoundException Didn't find class "com.google.android.gms.measurement.AppMeasurementInstallReferrerReceiver 引起:java.lang.ClassNotFoundException:没有找到类“okhttp3.internal.Platform” - Caused by: java.lang.ClassNotFoundException: Didn't find class "okhttp3.internal.Platform" Android Studio错误:原因:java.lang.ClassNotFoundException:未找到类 - Android Studio error: Caused by: java.lang.ClassNotFoundException: Didn't find class React Native java.lang.ClassNotFoundException:找不到类 - React Native java.lang.ClassNotFoundException: Didn't find class java.lang.ClassNotFoundException:在路径:DexPathList上找不到类… - java.lang.ClassNotFoundException: Didn't find class … on path: DexPathList java.lang.ClassNotFoundException:在路径上找不到 class:dexpathlist - java.lang.ClassNotFoundException: Didn't find class on path: dexpathlist java.lang.ClassNotFoundException:找不到带有TeamCity构建的类 - java.lang.ClassNotFoundException: Didn't find class with TeamCity build 调用Firebase方法getInstance错误。 java.lang.ClassNotFoundException:找不到类 - Invoke Firebase method getInstance error. java.lang.ClassNotFoundException: Didn't find class 原因:java.lang.ClassNotFoundException:找不到类“ com.google.android.gms.common.internal.zzbq” - Caused by: java.lang.ClassNotFoundException: Didn't find class “com.google.android.gms.common.internal.zzbq”
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM