Mac os 全局配置Android阿里云镜像
“在国内访问google一直是天朝程序员的困扰,即便有了科学上网方式,但是科学上网也有不行的时候,无奈还是配置了阿里云镜像,一劳永逸,从此开始飞一般的build速度”
1. 在当前用户的.gradle文件夹下新建init.gradle文件
2. 复制以下内容至init.gradle并保存,重新编译项目即可。
allprojects{
repositories {
def ALIYUN_REPOSITORY_URL = 'http://maven.aliyun.com/nexus/content/groups/public'
def ALIYUN_JCENTER_URL = 'http://maven.aliyun.com/nexus/content/repositories/jcenter'
def ALIYUN_GOOGLE_URL = 'http://maven.aliyun.com/nexus/content/repositories/google'
all { ArtifactRepository repo ->
if(repo instanceof MavenArtifactRepository){
def url = repo.url.toString()
if (url.startsWith('https://repo1.maven.org/maven2')) {
project.logger.lifecycle "Repository ${repo.url} replaced by $ALIYUN_REPOSITORY_URL."
remove repo
}
if (url.startsWith('https://jcenter.bintray.com/')) {
project.logger.lifecycle "Repository ${repo.url} replaced by $ALIYUN_JCENTER_URL."
remove repo
}
if (url.startsWith('https://dl.google.com/dl/android/maven2/')) {
project.logger.lifecycle "Repository ${repo.url} replaced by $ALIYUN_GOOGLE_URL."
remove repo
}
}
}
maven { url ALIYUN_GOOGLE_URL }
maven { url ALIYUN_REPOSITORY_URL }
maven { url ALIYUN_JCENTER_URL }
}
}