google / dagger

A fast dependency injector for Android and Java.
https://dagger.dev
Apache License 2.0
17.46k stars 2.02k forks source link

java.lang.IllegalStateException: Given component holder class com.avast.android.privacy.MainActivity does not implement interface dagger.hilt.internal.GeneratedComponent or interface dagger.hilt.internal.GeneratedComponentManager #2764

Closed MartinRajniak closed 3 years ago

MartinRajniak commented 3 years ago

When I upgrade to version 2.38 (2.37 previously) I get this error:

java.lang.IllegalStateException: Given component holder class does not implement interface dagger.hilt.internal.GeneratedComponent or interface dagger.hilt.internal.GeneratedComponentManager at dagger.hilt.EntryPoints.get(EntryPoints.java:62) at dagger.hilt.android.internal.lifecycle.HiltViewModelFactory.createInternal(HiltViewModelFactory.java:129) at androidx.hilt.navigation.HiltViewModelFactory.create(HiltNavBackStackEntry.kt:56) at androidx.hilt.navigation.compose.HiltViewModelKt.createHiltViewModelFactory(HiltViewModel.kt:107)

AGP version: 7.1.0-alpha03

Chang-Eric commented 3 years ago

Just to confirm, that activity you are passing in is annotated with @AndroidEntryPoint? And I assume you are using the Gradle plugin or extending the generated Hilt activity class?

wiryadev commented 3 years ago

i got this error too and i did annotate my activity with that. Rolled back to 2.37 solve this. Btw, i use Compose so i assume it is because hilt-navigation-compose is not updated to be compatible with 2.38.

MartinRajniak commented 3 years ago

Hi, yes, activity is annotated like this @AndroidEntryPoint class MainActivity : AppCompatActivity() {

Also I am using Android Hilt Gradle Plugin.

But I think @wiryadev is right - we are also using hilt navigation compose.

simonlebras commented 3 years ago

I'm also having this issue. Although I'm also using compose, I don't think this is related (might be wrong). I've a crash at startup (when using a custom entrypoint with jetpack startup and an application context to get some dependencies manually) caused by an IllegalStateException saying that my Application class does not implement GeneratedComponent . Rolling back to dagger 2.37 solved the issue for me as well

Chang-Eric commented 3 years ago

Thanks for the report, I believe this is happening due to #2784. Closing this as a duplicate assuming that is the case.

Badman47 commented 1 year ago

did anyone has an answer for this problem, Please

NguyenKhue commented 8 months ago

I got this error because i'm forgot implement: ksp(libs.hilt.compiler).

yash91989201 commented 1 month ago

Hi, yes, activity is annotated like this @AndroidEntryPoint class MainActivity : AppCompatActivity() {

Also I am using Android Hilt Gradle Plugin.

But I think @wiryadev is right - we are also using hilt navigation compose.

Adding the @AndroidEntryPoint fixed this error , I am new to this so I checked the documentation which said "Marks an Android component class to be setup for injection with the standard Hilt Dagger Android components"