Reputation:
my first project using Jetpack Compose got an error like this, how can I fix it
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.)
My dependencies:
dependencies {
classpath 'com.android.tools.build:gradle:7.0.0-beta03'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.4.30"
classpath "com.google.dagger:hilt-android-gradle-plugin:2.31.2-alpha"
}
Upvotes: 58
Views: 38819
Reputation: 7518
My app works now when I updated them:
com.android.tools.build:gradle:7.2.2
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-bin.zip
com.google.dagger:hilt-android:2.42
Upvotes: 1
Reputation: 4398
Updating hilt version to latest worked for me.
def hilt_version = '2.39.1'
Upvotes: 4
Reputation: 2214
Use Android Gradle plugin (AGP) version 7.0.3
+, for instance 7.1.0-rc01
or 7.2.0-alpha06
check in project level build gradle config
plugins {
id("com.android.application") version "7.0.4" apply false
id("org.jetbrains.kotlin.android") version "1.6.10" apply false
id("com.android.library") version "7.0.4" apply false
}
buildscript {
dependencies {
classpath("com.android.tools.build:gradle:7.0.4")
}
}
Upvotes: 3
Reputation: 5525
[UPDATE]: Currently, u can use Hilt 2.38
with gradle:7.1.0
dependencies {
classpath 'com.android.tools.build:gradle:7.1.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.10"
classpath "com.google.dagger:hilt-android-gradle-plugin:2.37"
}
if it doesn't work, let me know
Upvotes: 7
Reputation: 61
Use this dependency to your build.gradle file
classpath "com.android.tools.build:gradle:4.2.1"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'com.google.gms:google-services:4.3.8'
classpath "io.realm:realm-gradle-plugin:10.4.0"
classpath "com.google.dagger:hilt-android-gradle-plugin:2.35"
classpath "androidx.navigation:navigation-safe-args-gradle-plugin:2.3.5"
Upvotes: 2
Reputation: 5085
I was faced this same issue here is my changes
Upvotes: 1
Reputation: 367
in my solution , this work fine
Upvotes: 0
Reputation: 813
For me, I was used
Gradle
classpath "com.android.tools.build:gradle:7.0.3"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.31"
Hilt
Projet level gradle
classpath "com.google.dagger:hilt-android-gradle-plugin:2.39.1"
App level gradle
implementation "com.google.dagger:hilt-android:2.39.1"
kapt "com.google.dagger:hilt-compiler:2.39.1"
androidTestImplementation "com.google.dagger:hilt-android-testing:2.39.1"
kaptAndroidTest "com.google.dagger:hilt-android-compiler:2.39.1"
Upvotes: 11
Reputation: 13657
use the gradle plugin for Hilt 2.39.1:
classpath 'com.google.dagger:hilt-android-gradle-plugin:2.39.1'
and update the hilt version to 2.37:
implementation "com.google.dagger:hilt-android:2.37"
kapt "com.google.dagger:hilt-android-compiler:2.37"
Upvotes: 6
Reputation: 1038
just update to latest version of dagger hilt i,e, currently(2.38.1)
Upvotes: 5
Reputation: 3753
If you are using Hilt, upgrade it to v2.38.1 . Some problems with AGP 7 has been fixed in this release
See here : https://github.com/google/dagger/releases
Upvotes: 24
Reputation: 1210
In my case the problem was incompatibility between Android Gradle Plugin and Hilt library. After upgrading Hilt to the latest version, I can also use the latest AGP.
[EDIT]
It seems that recent release of Android Gradle Plugin has fixed the issue and
AGP version 7.0.0-beta05
works with Hilt version 2.37
.
Upvotes: 68