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

Android项目gradle同步报错Failed to resolve firebase相关依赖如何解决?

依赖解析失败解决办法

报错原因

  • com.google.firebase:firebase-core:20.0.2 版本不存在:Firebase官方自2021年起已拆分核心模块,不再单独发布firebase-core的独立高版本,20.0.2版本已从官方仓库下架。
  • com.google.firebase:firebase-ml-vision:24.1.3 依赖已废弃:Firebase ML Vision整套SDK已于2020年正式停止维护,所有旧版本均已从公共仓库移除,无法正常拉取。

修复步骤

  1. 删除build.gradle中无效的3行相关依赖:
implementation 'com.google.firebase:firebase-core:20.0.2'
implementation 'com.google.firebase:firebase-ml-vision:24.1.3'
implementation 'com.google.firebase:firebase-ml-vision-image-label-model:20.0.2'
  1. 替换为官方现行维护的替代依赖,推荐使用Firebase BoM统一管理版本避免版本冲突:
// 引入Firebase BoM,后续Firebase相关依赖无需单独指定版本号
implementation platform('com.google.firebase:firebase-bom:32.7.0')
// 原firebase-core对应的统计功能替换为analytics
implementation 'com.google.firebase:firebase-analytics'
// 原ML Vision图像标注功能替换为ML Kit官方替代组件
implementation 'com.google.mlkit:image-labeling:17.0.7'
// 如需使用设备端离线图像标注能力,额外添加如下依赖
implementation 'com.google.mlkit:image-labeling-common:17.0.1'
  1. 检查项目级build.gradle的仓库配置,确保已经添加Google官方仓库:
allprojects {
    repositories {
        google()
        mavenCentral()
    }
}
  1. 同步Gradle配置:点击Android Studio右上角的「Sync Project with Gradle Files」按钮,重新拉取依赖即可。

注意事项

如果必须兼容旧版ML Vision的代码逻辑,可以手动下载对应版本的aar包导入项目本地依赖,但该SDK已停止维护多年,存在安全漏洞和兼容性风险,不建议长期使用。


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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.09.23 14:15:04