Search code examples
androidgradledagger-hilt

The Hilt Android Gradle plugin is applied but no com.google.dagger:hilt-android-compiler dependency was found


I'm getting the error "The Hilt Android Gradle plugin is applied but no com.google.dagger:hilt-android-compiler dependency was found." while building the project.

Here's how I'm adding hilt to my project.

enter image description here

enter image description here

enter image description here

enter image description here


Solution

  • I guess you re missing this dependency

    kapt "com.google.dagger:hilt-android-compiler:2.28-alpha"

    *First add the plugin

    apply plugin: 'dagger.hilt.android.plugin'

    *Secondly add the dependencies

    // Dagger Core
    implementation "com.google.dagger:dagger:2.37"
    kapt "com.google.dagger:dagger-compiler:2.37"
    
    // Dagger Android
    api 'com.google.dagger:dagger-android:2.37'
    api 'com.google.dagger:dagger-android-support:2.37'
    kapt 'com.google.dagger:dagger-android-processor:2.37'
    
    // Dagger - Hilt
    implementation "com.google.dagger:hilt-android:2.37"
    kapt "com.google.dagger:hilt-android-compiler:2.37"
    

    *Thirdly add the classpath

    classpath "com.google.dagger:hilt-android-gradle-plugin:2.28-alpha"

    PS : if you re using java replace kapt with annotationProcessor