androidkotlindaggerdagger-hiltdynamic-feature

Hilt Error in Dynamic Feature component - Fragment does not implement GeneratedComponent or GeneratedComponentManager


I'm developing an app with a dynamic features that saves user's favorites, and I'm using Hilt for injection.

But I got this error:

java.lang.IllegalStateException: Given component holder class com.rmaprojects.favorite.presentation.FavoriteFragment 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.EntryPointAccessors.fromFragment(EntryPointAccessors.kt:66)
    at com.rmaprojects.favorite.presentation.FavoriteFragment.onAttach(FavoriteFragment.kt:38)

What I've done:

Any solution with this? Any help will be appreciated


Solution

  • I solved this a minute ago by simply changing the EntryPointAccessors.fromFragment() into *.fromApplication() (Change requireContext() into requireActivity().application)