方案一:切换镜像仓库
(原文地址)
阿里的仓库地址(亲测有效):http://maven.aliyun.com/nexus/content/groups/public/
OSChina的仓库地址:http://maven.oschina.net/content/groups/public/
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
maven{ url 'http://maven.aliyun.com/nexus/content/repositories/central/'}
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'
// 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/repositories/central/'}
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
以上方法下载有时会下载不了,替换后如下:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
// maven{ url 'http://maven.aliyun.com/nexus/content/repositories/central/'}
// maven()
maven { url 'http://maven.aliyun.com/nexus/content/groups/public/' }
maven { url 'http://maven.aliyun.com/nexus/content/repositories/jcenter' }
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'
// 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/repositories/central/'}
// maven()
maven { url 'http://maven.aliyun.com/nexus/content/groups/public/' }
maven { url 'http://maven.aliyun.com/nexus/content/repositories/jcenter' }
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
方案二:更换本地Gradle
(原文地址)
未经测试,自行查阅原文 O(∩_∩)O~~