1、在https://services.gradle.org/distributions/下载对应的gradle的zip包,对应方法见gradle-wrapper.properties文件中的:
distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip
将zip包放置于诸如“C:\Users\Administrator\.gradle\wrapper\dists\gradle-4.4-all\9br9xq1tocpiv8o6njlyu5op1”目录下
2、修改build.gradle
// Top-level build file where you can add configuration options common to all sub-projects/modules. buildscript { repositories {
google()
jcenter()
maven { url 'https://jitpack.io' }
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.2' // NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
} allprojects {
repositories {
google()
jcenter()
maven { url 'https://jitpack.io' }
}
} task clean(type: Delete) {
delete rootProject.buildDir
}
3、修改setting
mirrors.dormforce.net
4、也可以通过本地m2文件方式
在http://mirrors.neusoft.edu.cn/android/repository/
下载m2仓库:android_m2repository_r47.zip
将Android目录放入.m2目录
比如
- C:\Users\Administrator\.m2\repository\
- C:\Program Files\Android\Android Studio\gradle\m2repository\com\android
gradle实际上会先把依赖存放在cache中,读取也先从cache中读取,比如: