使用阿里雲映象 >> 解決AndroidStudio Gradle jar下載慢
阿新 • • 發佈:2019-02-19
AndroidStudio版本是3.0
到底要怎麼來配置呢?
在C盤的使用者包目錄下的~/.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
}
}
}
不過有的jar包是GitHub上的 則需要
allprojects {
repositories {
// 我這是下載com.github.CymChad:BaseRecyclerViewAdapterHelper需要的
maven {url "https://jitpack.io"}
}
}