Solution 1 :
Just Build -> Rebuild Project
worked for me.
If someone else has the same problem and rebuilding the project doesn’t work, feel free to comment your problem. If someone knows why it happens, please enlighten us with your answer.
Solution 2 :
For me none of the above worked. What fixed the issue was updating build tools and gradle wrapper to most recent versions.
Gradle wrapper from
distributionUrl=https://services.gradle.org/distributions/gradle-6.5-all.zip
to
distributionUrl=https://services.gradle.org/distributions/gradle-6.7-all.zip
And Build tools from
buildToolsVersion '29.0.1'
to
buildToolsVersion '29.0.3'
Solution 3 :
For me, i had a similar error because the Hilt gradle plugin was defined with different version than Hilt dependency.
classpath("com.google.dagger:hilt-android-gradle-plugin:2.38.1")
And Hilt dependency was:
implementation("com.squareup.retrofit2:retrofit:2.40")
Using 2.40
for both fixed it.
Problem :
I am using the new Hilt library for Dependency Injection version 2.28-alpha. I have followed the Hilt documentation and annotated the Application class with the @HiltAndroidApp
annotation. But when I am trying to build my project, its throwing a huge list of errors all similar to:
error: package {ApplicationClassName}_HiltComponents does not exist
public final class Dagger{ApplicationClassName}_HiltComponents_ApplicationC extends
{ApplicationClassName}_HiltComponents.ApplicationC {
I have searched for it but since its a new library, there is not much QnA available for it. Why is it throwing that error and how do I resolve it?
Comments
Comment posted by Taki
did you add the application class to your manifest file ?
Comment posted by Taki
Can you show your module and application class code ?
Comment posted by Ashu
@takieddine yes i already had my class added to the manifest. I don’t know but rebuilding the project worked. Thanks for your help
Comment posted by Udit
same problem. does anybody have any solution other than rebuilding because that didn’t help
Comment posted by Seven
Wow, I can’t believe this did the trick. I guess the issue was something that was left in cache and rebuilding the project just got rid of it…
Comment posted by Ashu
@Seven Yep. It happens quiet some times. Just
Comment posted by Udit
rebuilding the project is not helping me :/
Comment posted by Ashu
Hi @Udit… can you elaborate your problem? Have you tried invalidating cache as well? What’s happening on your end?
Comment posted by MJ Studio
This seems to a bug of Hilt itself. In my case, the renaming module class resolved this.
Comment posted by Sai
In my case I missed to update com.google.dagger:hilt-android version but I updated everywhere else.