Version: 2.29
As per release notes of Dagger 2.29 (https://github.com/google/dagger/releases/tag/dagger-2.29)
I've tried to change the compiler dependency to:
kapt "com.google.dagger:hilt-compiler:2.29-alpha"
This however doesn't work, if I have applied dagger.hilt.android.plugin. It says:
The Hilt Android Gradle plugin is applied but no com.google.dagger:hilt-android-compiler dependency was found.
Thanks! We can send out a patch for that soon.
In the mean time, you can continue using com.google.dagger:hilt-android-compiler. The new hilt-compiler artifact is just a rename.
Update: 2.29.1 should now be available with the fix.
Still having this issue on a multi-module android project with android gradle plugin 4.1.0
Hi @ThanosFisherman,
Can you check that you are using version com.google.dagger:hilt-android-gradle-plugin:2.29.1-alpha of the plugin?
Also check the error message for the failing Gradle module and verify that you've added the Hilt dependencies to that Gradle module. Note: You may need to go to the raw error message to find the failing Gradle module, as shown below:

If none of that helps, we would need a sample project or more explicit steps to reproduce the problem.
Hi @bcorso,
Thanks for pointing me to the right direction. Upon second look I realized that I had some unwanted lines in my gradle scripts that would consequently cause hilt to throw this error. After deleting those lines everything builds without errors, but now I do get runtime errors that I wouldn't get with hilt 2.28-alpha
java.lang.InstantiationException: java.lang.Class<AuthViewModel> has no zero argument constructor
But I suppose the error above is unrelated with this issue.
I'm also confused with the number of dependencies I should include as of the new hilt 2.29.1 Could you please verify that everything I included is correct?
I use hilt gradle plugin in my root gradle build file
com.google.dagger:hilt-android-gradle-plugin:2.29.1-alpha
then in my app level gradle file I added the following
kapt("com.google.dagger:hilt-compiler:2.29.1")
and
implementation("com.google.dagger:hilt-android:2.29.1")
also for viewmodel I use
implementation("androidx.hilt:hilt-lifecycle-viewmodel:1.0.0-alpha02")
and lastly I add the plugin id like so id("dagger.hilt.android.plugin")
And that's all. I did not included the hilt-core dependency whatsoever
@ThanosFisherman
java.lang.InstantiationException: java.lang.Class
has no zero argument constructor
Sounds like you maybe did not use @ViewModelInject for the constructor of your AuthViewModel...
something like this
class AuthViewModel @ViewModelInject constructor(
private val someDependency: SomeType
) : ViewModel() {}
You're saying you included this:
implementation("androidx.hilt:hilt-lifecycle-viewmodel:1.0.0-alpha02")
You actually need this dependency to enable that @ViewModelInject annotation. You wouldn't need that package if you wouldn't use that annotation. But in your case, you do need that package and you do need to use that annotation.
A few weeks ago I wrote a TLDR article with minimum setup of Dagger Hilt necessary, might be helpful to you to understand which dependencies you need to add:
https://medium.com/@vyletel/dagger-hilt-tldr-aa4fa361bf84
I'm already using @ViewModelInject in my ViewModels I did not have any problems with 2.28-alpha
Maybe I am missing something. I'll have a look at your article and if I still can't figure out what's causing this runtime crash, I'll create a sample project that reproduces this issue and post back. Probably I will open a new ticket as well.
Thanks
I'm also occurred this problem when migrating to hilt-compiler and shows the same error message
Does it needs to invalidate caches & restart first? *or deleting gradle/caches
@mochadwi have a look at this https://github.com/google/dagger/issues/2147 maybe you are missing something in your dependencies like I did
Agreed. After updating, add missing hilt dependency, invalidating, cleaning & rebuilding it works in my case.
Most helpful comment
Still having this issue on a multi-module android project with android gradle plugin 4.1.0