I updated the Android Studio to the latest version

2020-04-02 08:55发布

In an Android application,
I updated the Android Studio to the latest version (3.6.1)

Now when Syncing Gradle, the Gradle Plugin is not found with the errors as following:

Caused by: org.gradle.api.internal.artifacts.ivyservice.DefaultLenientConfiguration$ArtifactResolveException: Could not resolve all files for configuration ':classpath'.

And

Caused by: org.gradle.internal.resolve.ModuleVersionNotFoundException: Could not find com.android.tools.build:gradle:3.0.0.

It's driving me crazy cause I change the Gradle Version and Gradle Plugin Version to several other possibilities but again the Gradle Plugin is not found with the same error

Build.Gradle file:

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

buildscript {
    repositories {
        jcenter()
        google()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.0.0'
    }
}

allprojects {
    repositories {
        jcenter()
        google()
        maven { url "https://jitpack.io" }
    }
}

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

And Gradle.Wrappers.Properties file:

#Thu Mar 05 15:41:52 IRST 2020
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip

Edit :
I added the following data too:

Compile Sdk version: 25
Build Tools Version: 25.0.3

标签: android
5条回答
够拽才男人
2楼-- · 2020-04-02 09:20

Gradle sync failed: Could not find com.android.tools.build:gradle:3.6.1. Searched in the following locations: - https://jcenter.bintray.com/com/android/tools/build/gradle/3.6.1/gradle-3.6.1.pom - https://jcenter.bintray.com/com/android/tools/build/gradle/3.6.1/gradle-3.6.1.jar - https://maven.fabric.io/public/com/android/tools/build/gradle/3.6.1/gradle-3.6.1.pom - https://maven.fabric.io/public/com/android/tools/build/gradle/3.6.1/gradle-3.6.1.jar - https://repo.maven.apache.org/maven2/com/android/tools/build/gradle/3.6.1/gradle-3.6.1.pom - https://repo.maven.apache.org/maven2/com/android/tools/build/gradle/3.6.1/gradle-3.6.1.jar Required by: project : Consult IDE log for more details (Help | Show Log) (7 s 500 ms) having this issue again

Caused by: org.gradle.api.internal.artifacts.ivyservice.DefaultLenientConfiguration$ArtifactResolveException: Could not resolve all artifacts for configuration ':classpath'.

查看更多
看我几分像从前
3楼-- · 2020-04-02 09:23

I did not find a solution, the only thing was to return this In the built.gradle(project)

 classpath 'com.android.tools.build:gradle:3.6.1'

to this

 classpath 'com.android.tools.build:gradle:3.5.3'

and it worked!

查看更多
啃猪蹄的小仙女
4楼-- · 2020-04-02 09:27

This is what worked for me :

Open the build.gradle file from your app folder, it should look similar to this

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.6.1'
    }
}

allprojects {
    repositories {
        jcenter()
    }
}

add google() to repositories in -buildscript and allprojects just like this :

buildscript {
    repositories {
        google()       // here
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.6.1'
    }
}

allprojects {
    repositories {
        google()      //and here
        jcenter()
    }
}

In Android Studio, go to File -> Project Structure.. [ shortcut : Ctrl + Alt + Shift + S ]

In the Project tab -> Android Gradle Plugin Version -> 3.6.1 and Gradle Version -> 5.6.4 |||

Last, under the Module tab, make sure the compile sdk version is > 14 (ie: 25, 28 or 29..)

查看更多
男人必须洒脱
5楼-- · 2020-04-02 09:34

In your gradle-wrapper.properties file, change the distributionUrl to:

https://services.gradle.org/distributions/gradle-5.6.4-all.zip

The gradle-wrapper.properties file content should be like this:

#Wed Mar 11 00:28:24 EET 2020
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-all.zip
查看更多
Anthone
6楼-- · 2020-04-02 09:41

Another issue: using in a layout also causes problems. Android Studio will not 'find' the layout! Workaround: comment out the then un-comment it out. The build should now work!

查看更多
登录 后发表回答