Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Hilt implement issue - Expected @HiltAndroidApp to have a value

I'm having a issue implement Hilt on android app...

The error is:

Expected @HiltAndroidApp to have a value. Did you forget to apply the Gradle Plugin?

Project gradle file

buildscript {
    repositories {
        google()
        mavenCentral()
    }
    dependencies {
        //Hilt
        classpath 'com.google.dagger:hilt-android-gradle-plugin:2.38.1'

        classpath "com.android.tools.build:gradle:7.0.4"
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.20"
    }
}

Model gradle file

id 'kotlin-kapt'
id 'dagger.hilt.android.plugin'

dependencies {

    def dagger_hilt_android = "2.38.1"

    implementation("com.google.dagger:hilt-android:$dagger_hilt_android")
    kapt("com.google.dagger:hilt-android-compiler:$dagger_hilt_android")
}
like image 450
Mohammad H BaniHani Avatar asked Sep 01 '25 11:09

Mohammad H BaniHani


1 Answers

Mohmd.h.bh,

Try applying this plugin in your build.gradle of your Android Gradle

apply plugin: 'com.google.dagger.hilt.android'
android {
  // .......
}

I don't think you need to change the version of the kotlin-gradle-plugin

Regards

like image 157
Osoro Avatar answered Sep 02 '25 23:09

Osoro