国内网络,下载gradle和相关依赖库,十分缓慢,而且大概率会下载超时,常常抛出以下错误
Could not get resource 'https://jcenter.bintray.com/...'
解决方案:
使用阿里云的代理服务器,配置方法如下.
打开工程的build.gradle文件,增加阿里云的maven仓库地址
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
// 以下四行代码为阿里gradle 源
maven{ url 'https://maven.aliyun.com/repository/google'}
maven{ url 'https://maven.aliyun.com/repository/gradle-plugin'}
maven{ url 'https://maven.aliyun.com/repository/public'}
maven{ url 'https://maven.aliyun.com/repository/jcenter'}
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
// 以下四行代码为阿里gradle 源
maven{ url 'https://maven.aliyun.com/repository/google'}
maven{ url 'https://maven.aliyun.com/repository/gradle-plugin'}
maven{ url 'https://maven.aliyun.com/repository/public'}
maven{ url 'https://maven.aliyun.com/repository/jcenter'}
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
网友评论