In my project I have LoadingHandler class which is...
# dagger
b
In my project I have LoadingHandler class which is responsible for showing different kind of progress bars. I want to inject it in my fragments and attach its lifecycle to fragments view so I use ViewWithFragmentComponent but when I build my project it crashes with error which is telling me that LoadingHandler couldn't be provided. which is weird cause when I change ViewWithFragmentComponent to just FragmentComponent it works fine am I missing something?
a
FragmentComponent
is the parent of
ViewWithFragmentComponent
, and your Fragment class only can get dependencies from
FragmentComponent
and its parents, but not from its children. You can take a look at the components hierarchy from Hilt's docs. https://dagger.dev/hilt/components