There are many answers in SO regarding the above question, however my case is different, for me the setters for component is missing.
I have ApplicationComponent which depends on some other component [TestComponent] coming from a library.
@AppScope
@Component(
dependencies = [TestComponent::class],
modules = [
AppModule::class,
AndroidInjectionModule::class
]
)
interface AppComponent : AndroidInjector<MyApplication> {
override fun inject(application: MyApplication)
@ContextIO
fun getIOCoroutineContext(): CoroutineContext
@Component.Builder
interface Builder {
@BindsInstance
fun application(application: Application): Builder
@BindsInstance
fun testComponent(testComponent: TestComponent): Builder
fun build(): AppComponent
}
}
And the application class
class MyApplication : DaggerApplication() {
val appComponent by lazy {
DaggerAppComponent.builder()
.application(this)
.testComponent(SdkInjectors.testComponent())
.build()
}
}
@Singleton
@Component(
modules = {VideoModule.class, AnalyticsModule.class}
)
public interface TestComponent {
// ...
}