解決Android Studio Gradle jar包下載不了問題
剛使用這款IDE的時候遇到新建項目不能下載jar包
原因是網絡連接不通
通過代理完美解決網絡問題
- 修改配置文件 build.gradle
- 初始的配置文件:
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.5.3'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
}
}
- 增加阿里雲代理即可實現jar下載
buildscript {
repositories {
maven {
url 'https://maven.aliyun.com/repository/jcenter'
}
maven {
url 'https://maven.aliyun.com/repository/google'
}
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.5.3'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
maven {
url 'https://maven.aliyun.com/repository/jcenter'
}
maven {
url 'https://maven.aliyun.com/repository/central'
}
maven {
url 'https://maven.aliyun.com/repository/google'
}
jcenter()
mavenCentral()
google()
}
}
總結
主要是訪問地址不是國內的會出現連接超時
改爲國內代理既能快速下載jar包
又能提高開發效率
阿里雲倉庫地址