I have an Activity
called Activity1
, then inside has a Fragment1
all have the @ContributeAndroidInjection
and then if my Activity2
wants to inject Fragment1
Why I need to implement HasAndroidInjector
and do the
@Inject lateinit var androidInjector: DispatchingAndroidInjector<Any>
override fun androidInjector(): AndroidInjector<Any> = androidInjector
to be able to use a Fragment
that is already with @ContributeAndroidInjection
? If I remove this two lines it says :
RunTimeException:Unable to resume activity {MyActivity}: java.lang.IllegalArgumentException: No injector factory bound for Class
I thought that if I have this:
@ContributesAndroidInjector(
modules = [ FragmentProvider::class]
)
fun bindMyActivity2: Activity2
It would work anyways, because I've add as a modules a module that has inside the @ContributesAndroidInjector
with that Fragment...
Is it because I need that hasAndroidInjector
when I want to provide injection into a inner Fragment
?