https://kotlinlang.org logo
#dagger
Title
# dagger
b

Bacho Kurtanidze

10/12/2020, 9:09 AM
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

Ahmed Ibrahim

10/12/2020, 5:30 PM
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
4 Views