1. 搭建gradle环境
1.1 下载gradle
下载后进行相关配置
1.2 gradle配置国内镜像
1.2.1 添加配置文件
请在gradle的安装目录下的init.d的文件夹下添加init.gradle:
| 12
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 
 | gradle.projectsLoaded {rootProject.allprojects {
 buildscript {
 repositories {
 def JCENTER_URL = 'https://maven.aliyun.com/repository/public'
 def GOOGLE_URL = 'https://maven.aliyun.com/repository/google'
 def NEXUS_URL = 'https://maven.aliyun.com/repository/central'
 all { ArtifactRepository repo ->
 if (repo instanceof MavenArtifactRepository) {
 def url = repo.url.toString()
 if (url.startsWith('https://jcenter.bintray.com/')) {
 project.logger.lifecycle "Repository ${repo.url} replaced by $JCENTER_URL."
 println("buildscript ${repo.url} replaced by $JCENTER_URL.")
 remove repo
 }
 else if (url.startsWith('https://dl.google.com/dl/android/maven2/')) {
 project.logger.lifecycle "Repository ${repo.url} replaced by $GOOGLE_URL."
 println("buildscript ${repo.url} replaced by $GOOGLE_URL.")
 remove repo
 }
 else if (url.startsWith('https://repo1.maven.org/maven2')) {
 project.logger.lifecycle "Repository ${repo.url} replaced by $REPOSITORY_URL."
 println("buildscript ${repo.url} replaced by $REPOSITORY_URL.")
 remove repo
 }
 }
 }
 jcenter {
 url JCENTER_URL
 }
 google {
 url GOOGLE_URL
 }
 maven {
 url NEXUS_URL
 }
 }
 }
 repositories {
 def JCENTER_URL = 'https://maven.aliyun.com/repository/public'
 def GOOGLE_URL = 'https://maven.aliyun.com/repository/google'
 def NEXUS_URL = 'https://maven.aliyun.com/repository/central'
 all { ArtifactRepository repo ->
 if (repo instanceof MavenArtifactRepository) {
 def url = repo.url.toString()
 if (url.startsWith('https://jcenter.bintray.com/')) {
 project.logger.lifecycle "Repository ${repo.url} replaced by $JCENTER_URL."
 println("buildscript ${repo.url} replaced by $JCENTER_URL.")
 remove repo
 }
 else if (url.startsWith('https://dl.google.com/dl/android/maven2/')) {
 project.logger.lifecycle "Repository ${repo.url} replaced by $GOOGLE_URL."
 println("buildscript ${repo.url} replaced by $GOOGLE_URL.")
 remove repo
 }
 else if (url.startsWith('https://repo1.maven.org/maven2')) {
 project.logger.lifecycle "Repository ${repo.url} replaced by $REPOSITORY_URL."
 println("buildscript ${repo.url} replaced by $REPOSITORY_URL.")
 remove repo
 }
 }
 }
 jcenter {
 url JCENTER_URL
 }
 google {
 url GOOGLE_URL
 }
 maven {
 url NEXUS_URL
 }
 }
 }
 }
 
 | 
1.2.2 验证
项目重启后测试