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

Gradle构建中Firebase Crashlytics与动态模块依赖无法识别求助

解决Firebase依赖构建失败的方向和方法

1. 修正firebase-crashlytics-gradle的配置

这个是Gradle插件,不是普通的implementation依赖,不能放在app级依赖块里:

  • 打开项目级build.gradle.kts,在plugins块中声明插件(apply false表示先不应用):
    plugins {
        id("com.android.application") version "8.2.0" apply false
        id("com.google.firebase.crashlytics") version "2.9.9" apply false
        // 其他项目级插件...
    }
    
  • 回到app级build.gradle.kts,在plugins块中应用该插件:
    plugins {
        id("com.android.application")
        id("com.google.firebase.crashlytics")
        // 其他app级插件...
    }
    
  • 插件版本要和你的Android Gradle Plugin(AGP)版本匹配,比如AGP 8.x对应crashlytics插件2.9.x+,不用通过Firebase BoM管理。

2. 调整firebase-dynamic-module-support的依赖

这个库属于Firebase App Distribution的动态模块支持,正确的依赖写法是:

implementation("com.google.firebase:firebase-appdistribution-dynamic-module-support")
  • 如果BoM没有覆盖这个库的版本,单独指定兼容的版本号(要和你用的BoM版本匹配):
    implementation("com.google.firebase:firebase-appdistribution-dynamic-module-support:1.1.0")
    
  • 确认项目级build.gradle.kts的repositories里已经添加了google()仓库,Firebase库只在这里发布:
    repositories {
        google()
        mavenCentral()
    }
    

3. 清理Gradle缓存并强制刷新依赖

执行以下命令彻底清理缓存、刷新依赖后重新构建:

./gradlew clean build --refresh-dependencies

也可以手动删除本地Gradle缓存目录:

  • Mac/Linux:~/.gradle/caches
  • Windows:C:\Users\<你的用户名>\.gradle\caches

4. 验证BoM版本兼容性

确保你用的Firebase BoM版本和AGP、Kotlin版本兼容,比如最新的BoM 32.x.x对应AGP 8.2+、Kotlin 1.9+。app级build.gradle.kts里的BoM配置示例:

implementation(platform("com.google.firebase:firebase-bom:32.7.0"))

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.13 20:33:18