Android Studio 配置阿里云镜像

在电脑用户目录下的${USER_HOME}/.gradle/创建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'
    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
            }
        }
    }
    maven {
            url ALIYUN_REPOSITORY_URL
            url ALIYUN_JCENTER_URL
        }
    }
}

官方教程:https://docs.gradle.org/current/userguide/init_scripts.html

你可能感兴趣的:(Android,Android,Studio,Unity3d,android,maven,java)