Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable to find method ''void com.android.build.api.extension.AndroidComponentsExtension$DefaultImpls.androidTest$default(com.android.build

Tags:

android

kotlin

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.

Link to related Github issue


In my case AGP 7.0.0 builded successfully with Hilt 2.37


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


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"