如何解决Android项目构建报错:Could not find com.google.gms.google-services:4.3.15
解决构建错误:Could not find com.google.gms.google-services:4.3.15
错误详情
FAILURE: 构建因异常失败。
- 出错原因:
配置根项目“android”时出现问题。
无法解析配置':classpath'的所有文件。
Could not find com.google.gms.google-services:4.3.15。
依赖需求方:
项目 :
解决步骤
添加Google Maven仓库
打开根目录下的build.gradle文件,确保buildscript块中包含google()仓库(这是Google官方依赖的唯一合法仓库源):buildscript { repositories { google() mavenCentral() } dependencies { classpath 'com.google.gms:google-services:4.3.15' } }若之前使用的是
maven { url 'https://maven.google.com' },替换为google()即可,两者等效但后者是Android Studio推荐写法。校验依赖版本
若4.3.15版本已被移除或输入错误,可替换为当前稳定版本,比如:classpath 'com.google.gms:google-services:4.4.0'清理缓存并同步项目
- 点击Android Studio右上角的「Sync Project with Gradle Files」按钮同步项目
- 执行
File -> Invalidate Caches... -> Invalidate and Restart清理IDE缓存并重启
内容的提问来源于stack exchange,提问作者Ake
相关产品推荐
相关产品推荐

