Kotlin JC/Android Studio - Cant find Hilt

Hi.
I try to find a way to repair hilt, Android Studio cant find it.
Here’s some info
obraz
obraz


obraz
obraz

    implementation ("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.4")
    implementation ("org.jetbrains.kotlinx:kotlinx-coroutines-android:1.7.1")
    implementation( "org.jetbrains.kotlinx:kotlinx-coroutines-play-services:1.7.1")

    implementation ("androidx.lifecycle:lifecycle-viewmodel-ktx:2.6.2")
    implementation ("androidx.lifecycle:lifecycle-runtime-ktx:2.6.2")

    implementation ("com.google.dagger:hilt-android:2.48")

    kapt("com.google.dagger:hilt-android-compiler:2.40")
    implementation ("androidx.hilt:hilt-lifecycle-viewmodel:1.0.0-alpha03")
    implementation("androidx.hilt:hilt-navigation-compose:1.1.0")

    implementation ("com.squareup.retrofit2:retrofit:2.9.0")
    implementation ("com.squareup.retrofit2:converter-gson:2.9.0")

    implementation("androidx.core:core-ktx:1.12.0")
    implementation("androidx.lifecycle:lifecycle-runtime-ktx:2.6.2")
    implementation("androidx.activity:activity-compose:1.8.0")
    implementation(platform("androidx.compose:compose-bom:2023.03.00"))
    implementation("androidx.compose.ui:ui")
    implementation("androidx.compose.ui:ui-graphics")
    implementation("androidx.compose.ui:ui-tooling-preview")
    implementation("androidx.compose.material3:material3")
    testImplementation("junit:junit:4.13.2")
    androidTestImplementation("androidx.test.ext:junit:1.1.5")
    androidTestImplementation("androidx.test.espresso:espresso-core:3.5.1")
    androidTestImplementation(platform("androidx.compose:compose-bom:2023.03.00"))
    androidTestImplementation("androidx.compose.ui:ui-test-junit4")
    debugImplementation("androidx.compose.ui:ui-tooling")
    debugImplementation("androidx.compose.ui:ui-test-manifest")

Error is always the same (on pic).

1 Like

Do you have any plugins working? It looks like Gradle hasn’t resolved any of your plugins.

In my experience, if Gradle is broken, it really doesn’t recover well. I would try commenting out the hilt plugin and seeing if you can get everything else working and resolving, then try adding it again.

Yea, it was gradle, on course when i learn they dont say that and i lose few days to find a solution.

I found this: Gradle Build Setup

plugins {
  // other plugins...
  id 'com.google.dagger.hilt.android' version '2.48.1' apply false
}

That works for me (although I didn’t use the apply false; I think that’s only if you have a parent project with sub projects). Note that the plugin name is different (‘com.google.dagger.hilt.android’ vs ‘dagger.hilt.android.plugin’), and that a version is specified; it didn’t work until I specified a version.

1 Like