Gradle使用国内源(阿里云源)
2021-03-29 本文已影响0人
简单点的笨演员
Gradle在国内经常抽风,一直使用梯子来使用倒是没有出现什么问题,今天梯子被墙了,Gradle就用不了。最近好像查的有点严,估计梯子一时好不了,试试换gradle国内源。没有想到换了国内源比用梯子更快,故特在此记录一下。
关闭Gradle的代理(如果没有设置代理跳过这一步):
打开文件C:\Users\Administrator.gradle\gradle.properties,注释设置代理的行。
## For more details on how to configure your build environment visit
# http://www.gradle.org/docs/current/userguide/build_environment.html
#
# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
# Default value: -Xmx1024m -XX:MaxPermSize=256m
# org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
#
# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true
#Sat Jan 23 16:06:06 CST 2021
#systemProp.http.proxyHost=127.0.0.1
#systemProp.http.proxyPort=1081
#systemProp.https.proxyHost=127.0.0.1
#systemProp.https.proxyPort=1081
更换Gradle国内源
打开项目根目录的gradle.properties,注释所有google()和jcenter()的行,添加阿里云的源:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
// google()
// jcenter()
maven { url 'https://plugins.gradle.org/m2/' }
maven { url 'https://maven.aliyun.com/nexus/content/repositories/google' }
maven { url 'https://maven.aliyun.com/nexus/content/groups/public' }
maven { url 'https://maven.aliyun.com/nexus/content/repositories/jcenter'}
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
// google()
// jcenter()
maven { url 'https://plugins.gradle.org/m2/' }
maven { url 'https://maven.aliyun.com/nexus/content/repositories/google' }
maven { url 'https://maven.aliyun.com/nexus/content/groups/public' }
maven { url 'https://maven.aliyun.com/nexus/content/repositories/jcenter'}
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}