官方下载地址
https://services.gradle.org/distributions/
简友网盘下载
https://www.jianshu.com/p/d9329117aa2f
注意gradle需要配置jdk
下载配置
下载完成后解压到当前目录
image.png
配置到path环境变量中【;E:\kaifa\gradle\gradle-4.6-all\bin;】
在黑窗口中输入gradle -v
,返回版本信息表示配置成功
设置镜像
全局配置(操作系统的当前用户)
在操作系统当前用户的 HOME 目录,找到 .gradle 文件夹,在这个文件夹下面创建一个文本文件 init.gradle,完整的文件路径可能如下:C:\Users<june>.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
}
}
}
项目级配置(推荐)
修改buildscript->repositories
添加
allprojects {
repositories {
maven { url 'http://maven.aliyun.com/nexus/content/groups/public/' }
maven{ url 'http://maven.aliyun.com/nexus/content/repositories/jcenter'}
}
}
最后如下
buildscript {
repositories {
maven { url 'http://maven.aliyun.com/nexus/content/groups/public/' }
maven{ url 'http://maven.aliyun.com/nexus/content/repositories/jcenter'}
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.3'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
maven { url 'http://maven.aliyun.com/nexus/content/groups/public/' }
maven{ url 'http://maven.aliyun.com/nexus/content/repositories/jcenter'}
}
}
网友评论