java.lang.NoClassDefFoundError:解析失败:Lcom/google/firebase/appcheck/interop/InternalAppCheckTokenProvider;

问题描述 投票:0回答:2

昨天,在添加 Firebase 存储依赖项后,出现此错误。

FATAL EXCEPTION: main
Process: com.example.myapplication, PID: 12101
java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/firebase/appcheck/interop/InternalAppCheckTokenProvider;
    at com.google.firebase.database.DatabaseRegistrar.getComponents(DatabaseRegistrar.java:41)
    at com.google.firebase.tracing.ComponentMonitor.processRegistrar(ComponentMonitor.java:28)
    at com.google.firebase.components.ComponentRuntime.discoverComponents(ComponentRuntime.java:117)
    at com.google.firebase.components.ComponentRuntime.<init>(ComponentRuntime.java:99)
    at com.google.firebase.components.ComponentRuntime.<init>(ComponentRuntime.java:46)
    at com.google.firebase.components.ComponentRuntime$Builder.build(ComponentRuntime.java:387)
    at com.google.firebase.FirebaseApp.<init>(FirebaseApp.java:438)
    at com.google.firebase.FirebaseApp.initializeApp(FirebaseApp.java:295)
    at com.google.firebase.FirebaseApp.initializeApp(FirebaseApp.java:263)
    at com.google.firebase.FirebaseApp.initializeApp(FirebaseApp.java:248)
    at com.google.firebase.provider.FirebaseInitProvider.onCreate(FirebaseInitProvider.java:69)
    at android.content.ContentProvider.attachInfo(ContentProvider.java:1919)
    at android.content.ContentProvider.attachInfo(ContentProvider.java:1894)
    at com.google.firebase.provider.FirebaseInitProvider.attachInfo(FirebaseInitProvider.java:61)
    at android.app.ActivityThread.installProvider(ActivityThread.java:6391)
    at android.app.ActivityThread.installContentProviders(ActivityThread.java:5938)
    at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5853)
    at android.app.ActivityThread.access$1100(ActivityThread.java:199)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1650)
    at android.os.Handler.dispatchMessage(Handler.java:106)
    at android.os.Looper.loop(Looper.java:193)
    at android.app.ActivityThread.main(ActivityThread.java:6669)
    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 "com.google.firebase.appcheck.interop.InternalAppCheckTokenProvider" on path: DexPathList[[zip file "/data/app/com.example.myapplication-KK7_wlFnOM15nYO5wedr_g==/base.apk"],nativeLibraryDirectories=[/data/app/com.example.myapplication-KK7_wlFnOM15nYO5wedr_g==/lib/x86, /system/lib]]
    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.database.DatabaseRegistrar.getComponents(DatabaseRegistrar.java:41) 
    at com.google.firebase.tracing.ComponentMonitor.processRegistrar(ComponentMonitor.java:28) 
    at com.google.firebase.components.ComponentRuntime.discoverComponents(ComponentRuntime.java:117) 
    at com.google.firebase.components.ComponentRuntime.<init>(ComponentRuntime.java:99) 
    at com.google.firebase.components.ComponentRuntime.<init>(ComponentRuntime.java:46) 
    at com.google.firebase.components.ComponentRuntime$Builder.build(ComponentRuntime.java:387) 
    at com.google.firebase.FirebaseApp.<init>(FirebaseApp.java:438) 
    at com.google.firebase.FirebaseApp.initializeApp(FirebaseApp.java:295) 
    at com.google.firebase.FirebaseApp.initializeApp(FirebaseApp.java:263) 
    at com.google.firebase.FirebaseApp.initializeApp(FirebaseApp.java:248) 
    at com.google.firebase.provider.FirebaseInitProvider.onCreate(FirebaseInitProvider.java:69) 
    at android.content.ContentProvider.attachInfo(ContentProvider.java:1919) 
    at android.content.ContentProvider.attachInfo(ContentProvider.java:1894) 
    at com.google.firebase.provider.FirebaseInitProvider.attachInfo(FirebaseInitProvider.java:61) 
    at android.app.ActivityThread.installProvider(ActivityThread.java:6391) 
    at android.app.ActivityThread.installContentProviders(ActivityThread.java:5938) 
    at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5853) 
    at android.app.ActivityThread.access$1100(ActivityThread.java:199) 
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1650) 
    at android.os.Handler.dispatchMessage(Handler.java:106) 
    at android.os.Looper.loop(Looper.java:193) 
    at android.app.ActivityThread.main(ActivityThread.java:6669) 
    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) 

这是我的 gradle 构建:

plugins {
    id 'com.android.application'
    id 'com.google.gms.google-services'
}

android {
    namespace 'com.example.myapplication'
    compileSdk 33

    defaultConfig {
        applicationId "com.example.myapplication"
        minSdk 28
        targetSdk 33
        versionCode 1
        versionName "1.0"

        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
}

dependencies {

    implementation 'androidx.appcompat:appcompat:1.6.1'
    implementation 'com.google.android.material:material:1.5.0'
    implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
    implementation 'com.google.firebase:firebase-auth:21.3.0'
    implementation 'com.google.firebase:firebase-database:20.2.0'
    implementation 'com.google.firebase:firebase-storage:20.2.0'
    implementation 'com.google.firebase:firebase-storage-ktx:20.2.0'
    testImplementation 'junit:junit:4.13.2'
    androidTestImplementation 'androidx.test.ext:junit:1.1.5'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'


}

我尝试使用最新的Firebase存储版本,但仍然不起作用。我应该删除 firebase-storage 依赖项并再次添加吗?

ChatGPT 提到了这种依赖关系: 您的依赖项中可能缺少某个库:检查您的依赖项中是否包含所有必需的 Firebase 库。在这种情况下,您可能会缺少 Firebase App Check 库。

以前我从未使用过 firebase-app 检查依赖关系。

dependencies {
    // ...
    implementation 'com.google.firebase:firebase-appcheck:16.0.0-beta01'
    // ...
}
android-gradle-plugin noclassdeffounderror
2个回答
3
投票

好吧,我刚刚通过将所有 firebase-auth、firebase-database、material 更改为最新版本来解决了这个问题:

implementation 'com.google.firebase:firebase-auth:22.0.0'
implementation 'com.google.firebase:firebase-database:20.2.1'
implementation 'com.google.android.material:material:1.9.0'

0
投票

当我将存储依赖项更新到最新版本时,它就可以工作了

© www.soinside.com 2019 - 2024. All rights reserved.