如何解决原因:java.lang.ClassNotFoundException:找不到类“androidx.browser.customtabs.CustomTabsIntent$Builder”
Posted
技术标签:
【中文标题】如何解决原因:java.lang.ClassNotFoundException:找不到类“androidx.browser.customtabs.CustomTabsIntent$Builder”【英文标题】:How to fix Caused by: java.lang.ClassNotFoundException: Didn't find class "androidx.browser.customtabs.CustomTabsIntent$Builder" 【发布时间】:2021-03-31 15:43:12 【问题描述】:我正在尝试使用 firebase 通过电话号码实现 OTP 验证,但出现错误:
E/androidRuntime: FATAL EXCEPTION: main
Process: com.wasali.mobile_authentication, PID: 7864
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.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(com.google.firebase:firebase-auth@@20.0.1)
at android.os.AsyncTask.finish(AsyncTask.java:660)
at android.os.AsyncTask.-wrap1(AsyncTask.java)
at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:677)
at android.os.Handler.dispatchMessage(Handler.java:110)
at android.os.Looper.loop(Looper.java:203)
at android.app.ActivityThread.main(ActivityThread.java:6276)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1063)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:924)
Caused by: java.lang.ClassNotFoundException: Didn't find class "androidx.browser.customtabs.CustomTabsIntent$Builder" on path: DexPathList[[zip file "/data/app/com.wasali.mobile_authentication-1/base.apk"],nativeLibraryDirectories=[/data/app/com.wasali.mobile_authentication-1/lib/arm64, /system/lib64, /vendor/lib64, /system/vendor/lib64]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
at java.lang.ClassLoader.loadClass(ClassLoader.java:380)
at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
at com.google.firebase.auth.internal.RecaptchaActivity.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(com.google.firebase:firebase-auth@@20.0.1)
at android.os.AsyncTask.finish(AsyncTask.java:660)
at android.os.AsyncTask.-wrap1(AsyncTask.java)
at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:677)
at android.os.Handler.dispatchMessage(Handler.java:110)
at android.os.Looper.loop(Looper.java:203)
at android.app.ActivityThread.main(ActivityThread.java:6276)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1063)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:924)
我尝试了许多解决方案,例如添加此依赖项,但它不起作用:
implementation androidx.browser:browser:1.2.0
implementation 'com.google.firebase:firebase-auth'
implementation 'com.google.firebase:firebase-analytics'
implementation platform('com.google.firebase:firebase-bom:26.0.0')
【问题讨论】:
【参考方案1】:我遇到了同样的问题,请尝试关注-
//import broswer(require for firebase reCaptch Verifications)
implementation 'androidx.browser:browser:1.2.0'
// Import the Firebase BoM
implementation platform('com.google.firebase:firebase-bom:26.1.0')
implementation 'com.google.firebase:firebase-auth'
implementation 'com.google.firebase:firebase-analytics'
确保您输入apply plugin: 'com.google.gms.google-services' // Google Services plugin
在 build.gradle(app) 的顶部,并在 build.gradle(Project) 中添加一个依赖项,如下所示-
buildscript
repositories
google()
jcenter()
dependencies
classpath 'com.android.tools.build:gradle:3.5.0'
classpath 'com.google.gms:google-services:4.3.4' // Google Services plugin
如果您遇到错误,因为“仅从 Android N 开始支持静态接口方法”然后通过添加这些行将 Java 版本更新到 1.8 在你的 build.gradle(Project)
android
...
compileOptions
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
...
编码愉快!
【讨论】:
嘿,这确实有效,但仅对我来说,在我尝试构建我的项目时添加它后它失败并出现此错误 - 仅支持从 Android N 开始的静态接口方法?? @ItayFeldman 您可能需要更新 JavaVersion.VERSION_1_8... 否则山雀会向您显示该错误,请查看 this 了解更多信息,我也在编辑我的答案以上是关于如何解决原因:java.lang.ClassNotFoundException:找不到类“androidx.browser.customtabs.CustomTabsIntent$Builder”的主要内容,如果未能解决你的问题,请参考以下文章
ClassNotFoundException - com.mysql.jdbc.Driver / 导入 mysql-connector-java 后
从 PySpark 3.1.2 连接 Oracle DB - Py4JJavaError 失败
如何解决 NSInternalInconsistencyException',原因:'+entityForName:失败报告