① 【全局】配置 Android Studio 的 Gradle ,更改 service directory path
② 【项目】 gradle-wrapper.properties
distributionUrl=https\://services.gradle.org/distributions/gradle-3.1-bin.zip
修改成 如果 gradle_user_home没有分发版本也没有压缩版本,从url下载压缩版本到gradle_user_home\dists下面,然后在相同路径下分发。
distributionUrl=file:///F:/Dev/gradle/gradle-4.4.1-all.zip
【下载压缩包】https://services.gradle.org/distributions/
环境变量
GRADLE_HOME F:\Dev\gradle\gradle-4.4.1 本地具体版本Path
新增值:;%GRADLE_HOME%\bin
配置 F:\Dev\gradle\gradle.properties
org.gradle.jvmargs=-Xms1048m -Xmx4048m -XX:MaxPermSize=1024m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 org.gradle.parallel=true org.gradle.daemon=true
本地仓库
GRADLE_USER_HOME F:\Dev\gradle\repo 网上统一说法是 本地仓库
镜像 F:\Dev\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 } } }