dagger: 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)'
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
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 16
- Comments: 21 (3 by maintainers)
Commits related to this issue
- add hilt snapshot version as for issue: https://github.com/google/dagger/issues/2631 — committed to mengdd/compose-challenge-week4-weather-app by mengdd 3 years ago
- need later versions of hilt and gradle due to issue: https://github.com/google/dagger/issues/2631 — committed to scastrocalvo/Android-Quick-Start by scastrocalvo 3 years ago
@rock3r Well I had same problem, solved with AGP 7.1.0-alpha02, Gradle 7.0.2, and Hilt 2.37. Try this.
@ColtonIdle to use the snapshot version, add something like this to your buildsript
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.
I resolved the issue with: In project.gradle
In Build.gradle
I’m having the same issue with AGP 7.0 b04, Gradle 7.1, Dagger 2.37 and all dependencies to their latest versions:
EDIT: tried the snapshot, the sync completes but I’m having other issues when running, will update here when I figure it out
@gulabsagevadiya you shouldn’t have to rely on a snapshot version anymore since version 2.36 is released: https://github.com/google/dagger/issues/2634#issuecomment-848357196
@rock3r, @mwy3055, @slavonnet you are likely seeing a ‘reencarnacion’ of this issue, see: https://github.com/google/dagger/issues/2700
@b95505017 I’m new to “snapshots”. Can you let me know how you got this working?
@danysantiago It works when only use snapshot of the plugin!
This is a duplicate of https://github.com/google/dagger/issues/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/