Closed julioromano closed 3 years ago
Looks like the methods got renamed between beta03
and beta04
. We'll need to update Hilt's plugin to fix this. Sorry for the inconvenience.
Fun fact: this doesn't happen with AGP 7.0.0-alpha05 (which was released just one day earlier ).
On Fri, Jan 29, 2021, 17:21 Daniel Santiago notifications@github.com wrote:
Looks like the methods got renamed between beta03 and beta04 https://cs.android.com/android-studio/platform/tools/base/+/25384edea39fc22fc03097fb2e80908bf61b94d1. We'll need to update Hilt's plugin to fix this. Sorry for the inconvenience.
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/google/dagger/issues/2337#issuecomment-769903459, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAJW2JEDSX34N5Q25JJXATTS4LN7ZANCNFSM4WYPQZ3Q .
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.
It happened to me after upgrading Android Studio to 4.2.0.
Updating the hilt classpath on build.gradle to 2.35 fixed these issues for me.
classpath "com.google.dagger:hilt-android-gradle-plugin:2.35"
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
Please make sure that your hilt version will be same in project level and module level gradle. I've this issue in my project level gradle. 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"
I got the same error with Hilt 1.0.0 AGP 7.1.0-alpha01 Gradle gradle-7.0-bin
Android Studio Bumblebee | 2021.1.1 Canary 1 Build #AI-203.7717.56.2111.7361063, built on May 14, 2021 Runtime version: 11.0.10+0-b96-7249189 amd64 VM: OpenJDK 64-Bit Server VM by Oracle Corporation Windows 10 10.0 GC: G1 Young Generation, G1 Old Generation Memory: 1280M Cores: 4 Registry: external.system.auto.import.disabled=true Non-Bundled Plugins: org.jetbrains.kotlin
Same issue encountered in jetpack compose project using:
classpath 'com.android.tools.build:gradle:7.1.0-alpha01'
classpath "com.google.dagger:hilt-android-gradle-plugin:2.35.1"
implementation("com.google.dagger:hilt-android:2.35.1")
kapt("com.google.dagger:hilt-compiler:2.35.1")
kapt 'androidx.hilt:hilt-compiler:1.0.0'
Android Studio Bumblebee | 2021.1.1 Canary 1 Build #AI-203.7717.56.2111.7361063, built on May 14, 2021 Runtime version: 11.0.10+0-b96-7281165 x86_64 VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o. macOS 11.3.1 GC: G1 Young Generation, G1 Old Generation Memory: 4096M Cores: 16 Registry: external.system.auto.import.disabled=true Non-Bundled Plugins: org.jetbrains.kotlin
by using HEAD-SNAPSHOT the problem is fixed for now (as mentioned here -> #2631)
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"
}
The problem seems to still exist, the head-snapshot solution by @michal-th did not work either
2.35.1
worked on com.android.tools.build:gradle:7.0.0-beta02
, 2.36
works on com.android.tools.build:gradle:7.0.0-beta03
2.36
works on "com.android.tools.build:gradle:7.1.0-alpha02"
using AGP 7.0.0-beta04
and Hilt 2.37
, the same issue seems to persist...
@k4biri you are seeing a different but similar issue: https://github.com/google/dagger/issues/2700
using AGP
7.0.0-beta04
and Hilt2.37
, the same issue seems to persist...
Changing to classpath 'com.android.tools.build:gradle:7.1.0-alpha02'
should resolve the issue
I solved it with the following gradle settings.
app/build.gradle
dependencies {
implementation "com.google.dagger:hilt-android:2.37"
kapt "com.google.dagger:hilt-android-compiler:2.37"
implementation "androidx.hilt:hilt-lifecycle-viewmodel:1.0.0-alpha03"
kapt "androidx.hilt:hilt-compiler:1.0.0"
implementation 'androidx.hilt:hilt-navigation-compose:1.0.0-alpha03'
}
ROOT/build.gradle
dependencies {
classpath "com.android.tools.build:gradle:7.0.0"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.21"
classpath "com.google.dagger:hilt-android-gradle-plugin:2.37"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
So is AGP 7 a requirement for Hilt stable to work? (I'm on 6.1.1) Can anyone confirm? 🙏 There's no word about minimum version of AGP here https://dagger.dev/hilt/gradle-setup.html (the documentation of Hilt is otherwise super)
Versions: Hilt 2.31.2-alpha AGP 4.2.0-beta04 Gradle 6.8.1
Partial stacktrace: