最有效的解決方案:Unable to resolve dependency for ':app@debug/compileClasspath': Could not download xx.jar

網上百度和google了很久,無非就是關閉androidStudio的settings裏的gradle的offline。但是在我這並不好使。
根本原因是jcenter 不穩定造成的下載中斷

解決方案

1.修改項目下的build.gradle

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    
    repositories {
        google()
//       1 jcenter()
        maven{ url 'http://maven.aliyun.com/nexus/content/groups/public/'}
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.1.3'
        

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        google()
//      2  jcenter()
        maven{url 'http://maven.aliyun.com/nexus/content/groups/public/'}
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章