Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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'
like image 333
adwardwo1f Avatar asked Sep 06 '25 00:09

adwardwo1f


2 Answers

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

like image 53
Michaeljon Hayden Avatar answered Sep 07 '25 20:09

Michaeljon Hayden


There's some error with new version of Hilt, temporary fix for this is to add this maven part to top level gradle:

repositories {
    google()
    mavenCentral()
    maven {
        url  "https://oss.sonatype.org/content/repositories/snapshots"
        content {
            includeModule("com.google.dagger", "hilt-android-gradle-plugin")
        }
    }
}

Then Hilt class path look like this:

classpath("com.google.dagger:hilt-android-gradle-plugin:HEAD-SNAPSHOT")
like image 31
alfietap Avatar answered Sep 07 '25 20:09

alfietap