I was trying to implement HasActivityInjector in my android application but it's showing me HasActivityInjector cann't be resolved. Below dependencies and plugin I have used in my project-
apply plugin: 'kotlin-kapt'
and
implementation 'com.google.dagger:dagger:2.16'
kapt 'com.google.dagger:dagger-compiler:2.16'
Here is the code I am trying -
class RanoBoilerplateApplication : Application(), HasActivityInjector{
@Inject
lateinit var activityDispatchingAndroidInjector:
DispatchingAndroidInjector<Activity>
override fun onCreate() {
super.onCreate()
DaggerAppComponent.builder()
.application(this)
.build()
.inject(this)
}
override fun activityInjector(): AndroidInjector<Activity> =
activityDispatchingAndroidInjector
}
I don't know what other dependencies I must have to include to work that, help me if anyone have done this before.
Find the latest Dagger 2 version here.
Happy coding :-)
In case anyone comes here after updating to 2.24
, this was removed: https://github.com/google/dagger/commit/3bd8f707cb28fd0c5f3abb4f87658566f8b52c10.
You can use HasAndroidInjector
instead.