Skip to content

Instantly share code, notes, and snippets.

@Macrow
Last active October 31, 2022 09:47
Show Gist options
  • Save Macrow/2f34181533e103fb62955531501d78fd to your computer and use it in GitHub Desktop.
Save Macrow/2f34181533e103fb62955531501d78fd to your computer and use it in GitHub Desktop.
Android studio 统一替换JCenter为国内阿里云maven
摘要: jcenter替换为国内阿里云maven地址
在你的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
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment