方法一
修改根目录下的buil.gradle文件 allprojects { repositories { maven{ url 'http://maven.oschina.net/content/groups/public/'} } }
修改根目录下的buil.gradle文件
allprojects { repositories { maven{ url 'http://maven.oschina.net/content/groups/public/'} } }
方法二
将下面这段Copy到名为init.gradle文件中,并保存到 USER_HOME/.gradle/文件夹下即可 allprojects{ repositories { def REPOSITORY_URL = 'http://maven.oschina.net/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 } } } init.gradle文件其实是Gradle的初始化脚本(Initialization Scripts),也是运行时的全局配置
将下面这段Copy到名为init.gradle文件中,并保存到 USER_HOME/.gradle/文件夹下即可
allprojects{ repositories { def REPOSITORY_URL = 'http://maven.oschina.net/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 } } }