You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

添加Firebase Storage依赖后出现NoClassDefFoundError问题求助

解决Firebase依赖冲突导致的InternalAppCheckTokenProvider类找不到异常

问题根源

报错核心是Firebase Database组件初始化时,尝试加载com.google.firebase.appcheck.interop.InternalAppCheckTokenProvider类但未找到。这并非Storage依赖本身的问题,而是Firebase各组件版本不匹配,且缺失了组件间交互所需的interop依赖库。

解决方案

1. 统一所有Firebase组件版本

当前依赖中Firebase组件版本不一致(auth:21.3.0,database/storage:20.2.0),版本差异会导致依赖树中出现缺失或冲突的类。需将所有Firebase核心组件调整为相同的稳定版本:

  • 可选择将auth降级到20.2.0,与database/storage版本对齐;
  • 也可直接升级所有组件到最新稳定版(需确保版本兼容)。

2. 添加App Check Interop依赖

不需要引入完整的Firebase App Check库(包括你提到的beta版),只需添加组件间交互的interop依赖即可——这个库是Firebase内部组件共享的依赖:

implementation 'com.google.firebase:firebase-appcheck-interop:16.0.0'

3. 清理构建缓存

执行以下命令清理Gradle缓存,避免旧依赖残留影响构建:

./gradlew clean

之后重新同步项目并构建。

修改后的完整依赖示例

dependencies {
    implementation 'androidx.appcompat:appcompat:1.6.1'
    implementation 'com.google.android.material:material:1.5.0'
    implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
    // 统一Firebase组件版本为20.2.0
    implementation 'com.google.firebase:firebase-auth:20.2.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'
    // 添加interop依赖解决类缺失问题
    implementation 'com.google.firebase:firebase-appcheck-interop:16.0.0'
    testImplementation 'junit:junit:4.13.2'
    androidTestImplementation 'androidx.test.ext:junit:1.1.5'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
}

对你问题的直接答复

  • 无需移除重新添加Storage依赖:问题核心是版本不匹配和缺失interop库,而非Storage依赖本身的安装问题;
  • 无需引入beta版Firebase App Check库:只需添加上述firebase-appcheck-interop依赖即可解决类找不到的问题。

内容的提问来源于stack exchange,提问作者popadom

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.21 04:30:06