0.离线下载
/home/user用户名/.gradle/wrapper/dists
然后直接进入【gradle-4.4-all】》【9br9xq1tocpiv8o6njlyu5op1】文件夹
刚才复制的压缩包复制到当前文件夹下,然后解压出来。
grade
1.C:\Users\用户.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
}
}
}
2.android 工程根目录下的的build.gradle文件中配置国内阿里镜像库
阿里云镜像元
buildscript {
......
repositories {
maven { url 'http://maven.aliyun.com/repository/google' }
maven { url 'http://maven.aliyun.com/repository/jcenter' }
maven { url 'http://maven.aliyun.com/nexus/content/groups/public' }
maven { url 'http://maven.aliyun.com/nexus/content/repositories/gradle-plugin' }
google()
jcenter()
}
.....
}
........
allprojects {
repositories {
maven { url 'http://maven.aliyun.com/repository/google' }
maven { url 'http://maven.aliyun.com/repository/jcenter' }
maven { url 'http://maven.aliyun.com/nexus/content/groups/public' }
maven { url 'http://maven.aliyun.com/nexus/content/repositories/gradle-plugin' }
google()
jcenter()
}
}