今天打開(kāi)Android Studio鬼使神差去點(diǎn)了update到3.2.1起趾,升級(jí)完后工程就報(bào)錯(cuò)了。。瘤礁。
錯(cuò)誤日志:Unknown host 'd29vzk4ow07wi7.cloudfront.net'. You may need to adjust the proxy settings in Gradle
嘗試了各種方法批狱,還是報(bào)錯(cuò)裸准,比如(以下方法均在Project/build.gradle中修改):
方法1:把兩個(gè) jcenter() 用 maven{ url ‘http://maven.aliyun.com/nexus/content/groups/public/’}替換? --->? 報(bào)錯(cuò)
方法2:在jcenter()之前添加 maven{ url'http://maven.aliyun.com/nexus/content/groups/public/'}? --->? 可以下載之前報(bào)錯(cuò)的庫(kù),但allProject還是編譯出錯(cuò)
方法3:刪掉maven{ url'http://maven.aliyun.com/nexus/content/groups/public/'}赔硫,google()放在jcenter()前 ---> 搞定
修改后的 build.gradle 如下:
buildscript {
????repositories {
????????mavenCentral()
? ??????google()
? ??????jcenter()
????}
????dependencies {
????????classpath'com.android.tools.build:gradle:3.0.1'
? ? ????classpath'org.greenrobot:greendao-gradle-plugin:3.2.1'
? ? ????// NOTE: Do not place your application dependencies here; they belong
????????// in the individual module build.gradle files
? ????? }
????}
allprojects {
????repositories {
? ??????google()
? ??????jcenter()
????}
}
task clean(type: Delete) {
????delete rootProject.buildDir
}
總結(jié):google() 必須 在jcenter() 上炒俱,如果不行,就試試在 google() 下添加阿里云的鏡像maven{url'http://maven.aliyun.com/nexus/content/groups/public/'}