Search code examples
androidkotlindaggerdagger-hilt

Compose with Hilt last version (2.35) problem: Unable to find method


I'm trying to use Compose and Hilt (lastest version) on Android Canary, but i couldn't sync the project. Error message below:

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)'

My build.gradle

ext {
        compose_version = '1.0.0-beta01'
    }
    repositories {
        google()
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:7.1.0-alpha01'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.4.30"
        def hilt_version = "2.35"
        classpath "com.google.dagger:hilt-android-gradle-plugin:$hilt_version"
    }

My build.gradle(:app)

    //Dagger - Hilt
    def hilt_version = "2.35"
    implementation "com.google.dagger:hilt-android:$hilt_version"
    kapt "com.google.dagger:hilt-android-compiler:$hilt_version"
    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-alpha02'

Solution

  • Updating to hilt version 2.36 seems to have resolved this issue for me.