1、问题产生的原因?
因为要下载的文件需要翻墙。
2、解决的方法
修改项目根目录下 build.gradle 文件,将 jcenter() 或者 mavenCentral() 替换掉即可。可以用国内的仓库代替:
阿里的仓库地址:http://maven.aliyun.com/nexus/content/groups/public/
OSChina的仓库地址:http://maven.oschina.net/content/groups/public/
注意:必须注释掉 jcenter()。
repositories {
google()
// jcenter()
maven{url'https://maven.aliyun.com/repository/jcenter'}
}
allprojects {
repositories {
google()
maven {url"https://maven.google.com" }
maven{url'https://maven.aliyun.com/repository/jcenter'}
// jcenter()
}
}
如图配置就行了,问题完美解决!
网友评论