Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
976 views
in Technique[技术] by (71.8m points)

Android Studio Could not resolve all artifacts for configuration ':classpath'

I'm trying to run Android Studio on windows 10. Currently I have the most up to date version of Android Studio. Every time I try to open a new project or open an existing project, the gradle fails to build always displaying connection reset error message. This is the error message it displays.

> Could not resolve all artifacts for configuration ':classpath'.
   > Could not resolve com.android.tools.build:gradle:4.1.2.
     Required by:
         project :
      > Could not resolve com.android.tools.build:gradle:4.1.2.
         > Could not get resource 'https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/4.1.2/gradle-4.1.2.pom'.
            > Could not GET 'https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/4.1.2/gradle-4.1.2.pom'.
               > Connection reset
      > Could not resolve com.android.tools.build:gradle:4.1.2.
         > Could not get resource 'https://jcenter.bintray.com/com/android/tools/build/gradle/4.1.2/gradle-4.1.2.pom'.
            > Could not GET 'https://jcenter.bintray.com/com/android/tools/build/gradle/4.1.2/gradle-4.1.2.pom'.
               > Connection reset

I currently have the file gradle.build set up like this because this is how comes automatically for me

// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath "com.android.tools.build:gradle:4.1.2"

        // 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
}

And I have the gradle-wrapper.properties file set up like this

distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https://services.gradle.org/distributions/gradle-6.5-bin.zip

I have tried changing the line

distributionUrl=https://services.gradle.org/distributions/gradle-6.5-bin.zip

to

distributionUrl=https://services.gradle.org/distributions/gradle-6.5-all.zip

but that didn't change anything. I tried seeing if it was an Internet connection problem and nothing changed. I'm not sure what else there is to try.

question from:https://stackoverflow.com/questions/65838549/android-studio-could-not-resolve-all-artifacts-for-configuration-classpath

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Try to change the settings of the compiler, on my it was selected the option --offline, I just removed it and then started to work.

File>Settings>Build,exc,depl>compiler


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...