I have some class that looks like as below: But I have an issue, I cannot provide dependency for HomeRouter. So can you guys help me solve this problem:
class HomeRouter @Inject constructor (activity: Activity) : HomeContract.Router {
override fun finish() {
Timber.e("Finish")
}
}
and Module
@Module
abstract class RouterModule {
@Binds
abstract fun bindHomeRouter(homeRouter: HomeRouter):HomeRouter
}
and in AppComponent
@Singleton
@ActivityScope
@Component(
modules = [
ActivityBuilder::class,
AppModule::class,
NetworkModule::class,
AndroidSupportInjectionModule::class,
FragmentModule::class,
InteractorModule::class,
PresenterModule::class,
RouterModule::class
]
)
interface AppComponent : AndroidInjector<MyApplication> {
@Component.Builder
interface Builder {
@BindsInstance
fun application(application: MyApplication): Builder
fun build(): AppComponent
}
}
The exception as below:
/src/src/viper-architecture/app/build/tmp/kapt3/stubs/debug/com/appname/di/component/AppComponent.java:13: error: [Dagger/MissingBinding] android.app.Activity cannot be provided without an @Inject constructor or an @Provides-annotated method.
public abstract interface AppComponent extends dagger.android.AndroidInjector<com.appname.MyApplication> {
^
android.app.Activity is injected at
Thanks everyone.