Gradle Version 6.7.1 - Upgrade Failed

Viewed 4891

I have upgraded my Android Studio to 4.2 version few hours ago, and now when I opened one of my old projects I got a message from Android studio to upgrade Gradle version to 6.7.1. After I did that I got this error message and I can't build my project anymore... I also tried provided solutions from Android Studio, but with no success. Any help?

enter image description here

enter image description here

Error:

Unable to find method ''void com.android.build.api.extension.AndroidComponentsExtension$DefaultImpls.androidTest$default(com.android.build.api.extension.AndroidComponentsExtension, com.android.build.api.extension.VariantSelector, kotlin.jvm.functions.Function1, int, java.lang.Object)'' 'void com.android.build.api.extension.AndroidComponentsExtension$DefaultImpls.androidTest$default(com.android.build.api.extension.AndroidComponentsExtension, com.android.build.api.extension.VariantSelector, kotlin.jvm.functions.Function1, int, java.lang.Object)'

Gradle's dependency cache may be corrupt (this sometimes occurs after a network connection timeout.)

Re-download dependencies and sync project (requires network) The state of a Gradle build process (daemon) may be corrupt. Stopping all Gradle daemons may solve this problem.

Stop Gradle build processes (requires restart) Your project may be using a third-party plugin which is not compatible with the other plugins in the project or the version of Gradle requested by the project.

In the case of corrupt Gradle processes, you can also try closing the IDE and then killing all Java processes.

4 Answers

if you us dagger hilt change the version of dagger hilt

Using a combination of

Hilt version 2.35 Android Studio version 4.2 Android Gradle Plugin version 4.2.0 Gradle version to 6.7.1

worked for me

documentaire https://github.com/google/dagger/issues/2337

This solution from the Dagger Github solved it for me. https://github.com/google/dagger/issues/2337

repositories {
        /*  ...  */
         maven {
            url  "https://oss.sonatype.org/content/repositories/snapshots"
            content {
                includeModule("com.google.dagger", "hilt-android-gradle-plugin")
            }
        }
}

    dependencies {
       
        classpath "com.google.dagger:hilt-android-gradle-plugin:HEAD-SNAPSHOT"
        
    }

Please make sure that your dependencies have the same version on both project level and module level Gradle files. I've this issue in my project level Gradle when I was updating Hilt version. I've updated the version to 2.35 in module level but forgot to update it in project-level Gradle. It worked for me when I update it in both.

classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"

Change your gradle version to 7.0.0-alpha15

This worked for me after I tried all the other suggestions here.

Related