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

能否同时使用jcenter()和mavenCentral()实现Firebase集成?

可以同时配置jcenter()与mavenCentral()、google()仓库满足需求

完全可以同时配置这三个仓库,既能顺利完成Firebase集成,也能正常拉取仅存在于jcenter()的依赖库。

Gradle会按照你声明仓库的顺序依次查找依赖包,你当前的配置中,先通过google()和mavenCentral()获取Firebase相关的依赖,再从jcenter()拉取你的原有依赖,这个逻辑是通顺的,不会出现冲突。

需要注意的是:

  • jcenter已经在2021年停止更新并进入归档状态,目前仅能拉取已存在的依赖包,不会有新的内容上传。如果你的这两个依赖没有替代方案,暂时用jcenter()是可行的,但长期来看建议关注依赖的迁移计划,尽量转到mavenCentral()或其他活跃的仓库,避免后续jcenter完全下线带来的问题。
  • 你提供的build.gradle配置写法是正确的,在buildscript和allprojects的repositories块中同时添加三个仓库的方式符合Gradle规范,可以直接使用。
repositories {
    // Make sure that you have the following two repositories
    google()  // Google's Maven repository

    mavenCentral()  // Maven Central repository
    jcenter() //code added by me to the guide's code
  }
  dependencies {
    ...
    // Add the dependency for the Google services Gradle plugin
    classpath 'com.google.gms:google-services:4.3.13'

  }
}

allprojects {
  ...
  repositories {
    // Make sure that you have the following two repositories
    google()  // Google's Maven repository

    mavenCentral()  // Maven Central repository
    jcenter() //code added by me to the guide's code

  }
}

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.21 16:54:17