Android studio 统一替换JCenter为国内阿里云

2017-11-17  本文已影响760人  xiaolei123

在你的USER_HOME/.gradle/目录下,新建一个文件init.gradle

把这一段内容拷贝进去


allprojects{
    repositories {
        def REPOSITORY_URL = 'http://maven.aliyun.com/nexus/content/groups/public/'
        all { ArtifactRepository repo ->
            if(repo instanceof MavenArtifactRepository){
                def url = repo.url.toString()
                if (url.startsWith('https://repo1.maven.org/maven2') || url.startsWith('https://jcenter.bintray.com/')) {
                    project.logger.lifecycle "Repository ${repo.url} replaced by $REPOSITORY_URL."
                    remove repo
                }
            }
        }
        maven {
            url REPOSITORY_URL
        }
    }
}

上一篇 下一篇

猜你喜欢

热点阅读