https://blog.csdn.net/mars314/article/details/81910789
方法一:
https 改成 http 協議下載,修改項目根目錄下 build.gradle
文件:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
// jcenter()
jcenter(){url 'http://jcenter.bintray.com/'}
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
// jcenter()
jcenter(){url 'http://jcenter.bintray.com/'}
}
}
親測,此方法有效。
方法二:
切換到國內的Maven鏡像倉庫。
修改項目根目錄下 build.gradle 文件,將 jcenter() 或者 mavenCentral() 替換掉即可。可以用國內的倉庫代替:
阿里的倉庫地址:http://maven.aliyun.com/nexus/content/groups/public/
OSChina的倉庫地址:http://maven.oschina.net/content/groups/public/
buildscript {
repositories {
maven{url"https://maven.google.com"}
maven{ url 'http://maven.aliyun.com/nexus/content/repositories/central/'}
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.3'
}
}
allprojects {
repositories {
maven{url"https://maven.google.com"}
maven{ url 'http://maven.aliyun.com/nexus/content/repositories/central/'}
jcenter()
}
gradle.projectsEvaluated {
tasks.withType(JavaCompile) {
options.encoding = "UTF-8"
}
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
阿里的這個有效。
方法三:
手機開熱點,電腦連接上手機熱點,用手機完成;
親測有效。
方法四:
萬能方法,此方法怎麼着都行,離線gradle都成。下載https://download.csdn.net/download/mars314/10618153覆蓋你的gradle,可解決無法下jcenter緩慢超時問題!
總結:原地址:https:// jcenter.bintray.com/一亙有一次下載成功了,以後都會成功。修改協議:後續工程也得修改協議/
------------------