Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

java.lang.NoSuchMethodError: 'void com.android.build.api.extension.AndroidComponentsExtension$DefaultImpls.androidTests$default(com.android.build.api.extension.AndroidComponentsExtension, com.android.build.api.extension.VariantSelector, kotlin.jvm.functions.Function1, int, java.lang.Object)' #2631

Closed
ColtonIdle opened this issue May 19, 2021 · 21 comments

Comments

@ColtonIdle
Copy link

Studio Build: BB canary1 Version of Gradle Plugin: 7.1 alpha01 Version of Gradle: 7.0.2

I have a project that is updated and work with Arctic Fox beta01 and AGP 7.0 beta01.

I installed bumblebee and got the upgrade assistant. After hitting the accept button I can see in git that the diff is:

-         classpath("com.android.tools.build:gradle:7.0.0-beta01")
+         classpath("com.android.tools.build:gradle:7.1.0-alpha01")

For reference here are my hilt dependency declarations

        classpath("com.google.dagger:hilt-android-gradle-plugin:2.35.1")


and


    implementation("com.google.dagger:hilt-android:2.35.1")
    kapt("com.google.dagger:hilt-compiler:2.35.1")


and

    implementation("androidx.hilt:hilt-navigation-fragment:1.0.0")
    implementation("androidx.hilt:hilt-navigation:1.0.0")

When I hit clean or sync I get the following error:

Unable to find method ''void com.android.build.api.extension.AndroidComponentsExtension$DefaultImpls.androidTests$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.androidTests$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.
* Exception is:
java.lang.NoSuchMethodError: 'void com.android.build.api.extension.AndroidComponentsExtension$DefaultImpls.androidTests$default(com.android.build.api.extension.AndroidComponentsExtension, com.android.build.api.extension.VariantSelector, kotlin.jvm.functions.Function1, int, java.lang.Object)'
	at dagger.hilt.android.plugin.HiltGradlePlugin.configureTransformASM(HiltGradlePlugin.kt:239)
	at dagger.hilt.android.plugin.HiltGradlePlugin.configureHilt(HiltGradlePlugin.kt:79)
	at dagger.hilt.android.plugin.HiltGradlePlugin.access$configureHilt(HiltGradlePlugin.kt:50)
	at dagger.hilt.android.plugin.HiltGradlePlugin$apply$1.execute(HiltGradlePlugin.kt:57)
	at dagger.hilt.android.plugin.HiltGradlePlugin$apply$1.execute(HiltGradlePlugin.kt:50)

Originally filed here before I saw Hilt in the stacktrace: https://issuetracker.google.com/issues/188563075

@Tgo1014
Copy link

Tgo1014 commented May 19, 2021

I'm having the same issue. Any workaround? Is there a way to make Canary run with an old alpha version? The latest stable breaks my .kts files.

@shakil807g
Copy link

Having same issue with

AGP:
classpath "com.android.tools.build:gradle:7.1.0-alpha01"

@slavonnet
Copy link

I'm having the same issue. Any workaround? Is there a way to make Canary run with an old alpha version? The latest stable breaks my .kts files.

You can run beta. Its work and its like cannary 15

@danysantiago
Copy link
Member

This is a duplicate of #2618, its fixed but we haven't made a release, if you want to get unblock you can use snapshot versions of Hilt from https://oss.sonatype.org/content/repositories/snapshots/com/google/dagger/

@b95505017
Copy link

@danysantiago I tried snapshot but get this error:

MyApplication_ComponentTreeDeps.java:197: error: cannot find symbol
@ComponentTreeDeps(
 ^
  symbol: class ComponentTreeDeps

@danysantiago
Copy link
Member

@b95505017 thats not good... can you try only using the HEAD-SNAPSHOT version of the plugin and keep the rest of the dependencies as you had them?

I need to investigate why that symbol is not found, when it is here

@b95505017
Copy link

@danysantiago It works when only use snapshot of the plugin!

@ColtonIdle
Copy link
Author

@b95505017 I'm new to "snapshots". Can you let me know how you got this working?

@SimonMarquis
Copy link

@ColtonIdle to use the snapshot version, add something like this to your buildsript

buildscript {
    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")
    }
}

@ColtonIdle
Copy link
Author

Thank you @SimonMarquis that helped! Really appreciate it!

@gulabsagevadiya
Copy link

gulabsagevadiya commented Jun 8, 2021

@ColtonIdle to use the snapshot version, add something like this to your buildsript

buildscript {
    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")
    }
}

i got this error while using this

A problem occurred evaluating root project 'ComposeTrailApp'.
Could not set unknown property 'url' for repository container of type org.gradle.api.internal.artifacts.dsl.DefaultRepositoryHandler.

Any Idea what to do

@SimonMarquis
Copy link

@gulabsagevadiya you shouldn't have to rely on a snapshot version anymore since version 2.36 is released: #2634 (comment)

@rock3r
Copy link

rock3r commented Jun 17, 2021

I'm having the same issue with AGP 7.0 b04, Gradle 7.1, Dagger 2.37 and all dependencies to their latest versions:

image

EDIT: tried the snapshot, the sync completes but I'm having other issues when running, will update here when I figure it out

@mwy3055
Copy link

mwy3055 commented Jun 17, 2021

@rock3r Well I had same problem, solved with AGP 7.1.0-alpha02, Gradle 7.0.2, and Hilt 2.37. Try this.

@slavonnet
Copy link

slavonnet commented Jun 17, 2021

try kapt.use.worker.api=false
ub feadkle pro

also try commentr plugin appoly, sync, look for errors (plugin not appliex if errors in sync and sync syccess becouse its can''t find added dependencyu), uncomment, sync

I'm having the same issue with AGP 7.0 b04, Gradle 7.1, Dagger 2.37 and all dependencies to their latest versions:

image

EDIT: tried the snapshot, the sync completes but I'm having other issues when running, will update here when I figure it out

@danysantiago
Copy link
Member

@rock3r, @mwy3055, @slavonnet you are likely seeing a 'reencarnacion' of this issue, see: #2700

scastrocalvo added a commit to scastrocalvo/Android-Quick-Start that referenced this issue Jun 25, 2021
@olala2288
Copy link

I have the same issue, I don't know why google changes these crucial dependencies every time with no backward compatibility so we should spend hours to fix these.

@rafsanahmad
Copy link

rafsanahmad commented Dec 21, 2021

I resolved the issue with:
In project.gradle

classpath 'com.android.tools.build:gradle:7.0.4' 
classpath "com.google.dagger:hilt-android-gradle-plugin:2.38.1"

In Build.gradle

implementation "com.google.dagger:hilt-android:2.38.1"
kapt "com.google.dagger:hilt-android-compiler:2.38.1"

@danielandrioli
Copy link

Goddamn, I spend some hours trying to fix this issue.

@rafsanahmad answer worked for me, finally. Thanks, man!
I'm using now Hilt's 2.38.1 version. The only difference is I'm using 7.1.1 for Gradle.

@arjun-sharma-acn
Copy link

arjun-sharma-acn commented Mar 22, 2022

@rafsanahmad Thank you for ur answer....it worked for me

@P3t3rP3r3z
Copy link

@rafsanahmad solution worked for me! thanks! also used @danielandrioli advice and used 7.1.1 gradle

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests