Could not resolve all artifacts for configuration ':classpath';

445 阅读1分钟
Could not resolve all artifacts for configuration ':classpath'.
   > Could not download jetifier-processor.jar (com.android.tools.build.jetifier:jetifier-processor:1.0.0-beta08)
      > Could not get resource 'https://maven.google.com/com/android/tools/build/jetifier/jetifier-processor/1.0.0-beta08/jetifier-processor-1.0.0-beta08.jar'.
         > Could not HEAD 'https://maven.google.com/com/android/tools/build/jetifier/jetifier-processor/1.0.0-beta08/jetifier-processor-1.0.0-beta08.jar'.
            > Connect to maven.google.com:443 [maven.google.com/172.217.160.78] failed: Connection timed out: connect
   > Could not download bundletool.jar (com.android.tools.build:bundletool:0.10.3)
      > Could not get resource 'https://maven.google.com/com/android/tools/build/bundletool/0.10.3/bundletool-0.10.3.jar'.
         > Could not HEAD 'https://maven.google.com/com/android/tools/build/bundletool/0.10.3/bundletool-0.10.3.jar'.
            > Connect to maven.google.com:443 [maven.google.com/172.217.160.78] failed: Connection timed out: connect
   > Could not download jetifier-core.jar (com.android.tools.build.jetifier:jetifier-core:1.0.0-beta08)
      > Could not get resource 'https://maven.google.com/com/android/tools/build/jetifier/jetifier-core/1.0.0-beta08/jetifier-core-1.0.0-beta08.jar'.
         > Could not HEAD 'https://maven.google.com/com/android/tools/build/jetifier/jetifier-core/1.0.0-beta08/jetifier-core-1.0.0-beta08.jar'.
            > Connect to maven.google.com:443 [maven.google.com/172.217.160.78] failed: Connection timed out: connect

打开以前的项目build报错,一刚开始以为是AS升级后引发的问题,用老版本的AS打开依然报这个错,上网百度了一下,原因可能是资源库下载不下来,解决方法是在project的build.gradle中加上aliyun的镜像下载链接完美解决:

buildscript {
    repositories {
        maven { url 'http://maven.aliyun.com/nexus/content/groups/public/'}
        maven { url'https://maven.aliyun.com/repository/public/' }
        maven { url'https://maven.aliyun.com/repository/google/' }
        maven { url'https://maven.aliyun.com/repository/jcenter/' }
        maven { url'https://maven.aliyun.com/repository/central/' }
        mavenLocal()
        
        jcenter(){ url 'https://jcenter.bintray.com/'}
        mavenCentral()
        maven {
            url 'https://maven.google.com'
        }
        google()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.6.4'
        classpath 'com.google.gms:google-services:4.3.13'
        classpath 'com.jakewharton:butterknife-gradle-plugin:10.2.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/groups/public/'}
        maven { url'https://maven.aliyun.com/repository/public/' }
        maven { url'https://maven.aliyun.com/repository/google/' }
        maven { url'https://maven.aliyun.com/repository/jcenter/' }
        maven { url'https://maven.aliyun.com/repository/central/' }
        mavenLocal()

        jcenter(){ url 'https://jcenter.bintray.com/'}
        google()
        maven { url "https://jitpack.io" }
    }
}

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