question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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

See original GitHub issue

Hilt Version: 2.36 Compose Project Android Studio Bumblebee | 2021.1.1 Canary 1 Build #AI-203.7717.56.2111.7361063, built on May 14, 2021 Runtime version: 11.0.10+0-b96-7281165 x86_64 VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o. macOS 11.4

Depends:

        const val gradleVersion = "7.1.0-alpha01"
        const val hiltVersion = "2.36"
        const val hiltCompilerVersion = "1.0.0"
        const val hilt_android = "com.google.dagger:hilt-android:${Versions.hiltVersion}"
        const val hilt_android_compiler = "com.google.dagger:hilt-android-compiler:${Versions.hiltVersion}"
        const val hilt_compiler = "androidx.hilt:hilt-compiler:${Versions.hiltCompilerVersion}"
        const val hilt_android_gradle_plugin = "com.google.dagger:hilt-android-gradle-plugin:${Versions.hiltVersion}"

Root’s build.gradle:

buildscript {
...
    dependencies {
        ...
        classpath(app.web.drjackycv.buildsrc.Depends.ClassPaths.hilt_android_gradle_plugin)

App’s build.gradle:

plugins {
    id("com.android.application")
    kotlin("android")
    id("kotlin-parcelize")
    kotlin("kapt")
    id("dagger.hilt.android.plugin")
}
...
dependencies {
...
    //dependency injection
    implementation(Depends.Libraries.hilt_android)
    kapt(Depends.Libraries.hilt_android_compiler)
    kapt(Depends.Libraries.hilt_compiler)
    implementation(Depends.Libraries.java_inject)
...

Domain’s build.gradle:

plugins {
    id("com.android.library")
    kotlin("android")
    id("kotlin-parcelize")
    kotlin("kapt")
    id("dagger.hilt.android.plugin")
}
...
dependencies {
    //dependency injection
    implementation(Depends.Libraries.hilt_android)
    kapt(Depends.Libraries.hilt_android_compiler)
    kapt(Depends.Libraries.hilt_compiler)

Data’s build.gradle:

plugins {
    id("com.android.library")
    kotlin("android")
    id("kotlin-parcelize")
    kotlin("kapt")
    id("dagger.hilt.android.plugin")
}
...
dependencies {
    //dependency injection
    implementation(Depends.Libraries.hilt_android)
    kapt(Depends.Libraries.hilt_android_compiler)
    kapt(Depends.Libraries.hilt_compiler)
    implementation(Depends.Libraries.java_inject)

Presentation’s build.gradle:

plugins {
    id("com.android.library")
    kotlin("android")
    id("kotlin-parcelize")
    kotlin("kapt")
    id("androidx.navigation.safeargs.kotlin")
    id("dagger.hilt.android.plugin")
}
...
dependencies {
    //dependency injection
    implementation(Depends.Libraries.hilt_android)
    kapt(Depends.Libraries.hilt_android_compiler)
    kapt(Depends.Libraries.hilt_compiler)
    implementation(Depends.Libraries.java_inject)

And it doesn’t matter if I only use hilt_android_compiler or only hilt_compiler.

Sample project: https://github.com/Drjacky/MVVMTemplate/tree/feature/compose

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:7
  • Comments:22 (4 by maintainers)

github_iconTop GitHub Comments

12reactions
alvindizoncommented, Aug 21, 2021

The answer for this SO question worked for me

7reactions
danysantiagocommented, Jun 22, 2021

I’ve created a detailed issue to the Android Studio team regarding this issue: https://issuetracker.google.com/191717152

Based on my findings, the ‘missing Hilt dependency’ error is being wrongly shown when you have an error in your Kotlin+gradle build.gradle.kts file.

So far I haven’t found a workaround…

Read more comments on GitHub >

github_iconTop Results From Across the Web

The Hilt Android Gradle plugin is applied but no com.google ...
google.dagger:hilt-android-compiler dependency was found." while building the project. Here's how I'm adding hilt to my project.
Read more >
Gradle Build Setup - Dagger
dependencies { implementation 'com.google.dagger:hilt-android:2.44.2' ... then apply the kapt plugin and declare the compiler dependency using kapt instead ...
Read more >
Dependency injection with Hilt | Android Developers
Android Developers · Docs More. Platform Android Studio Google Play Jetpack Kotlin Games. Language. English · Bahasa Indonesia · Español – América Latina ......
Read more >
com.google.dagger » hilt-android-gradle-plugin
Version Vulnerabilities Repository Usages Date 2.44.x 2.44.2 Central 1 Nov 14, 2022 2.44.1 2.44.x Central 1 Nov 11, 2022 2.44 2.44.x Central 1 Sep 22, 2022...
Read more >
com.google.dagger : hilt-android-gradle-plugin : 2.32-alpha
Hilt Android Gradle Plugin - A fast dependency injector for Android and Java.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found