https://kotlinlang.org logo
Title
d

Damien O'Reilly

04/20/2019, 2:18 PM
I have been following https://github.com/google/iosched/blob/2696fc7e06/mobile/src/main/java/com/google/samples/apps/iosched/di/AppComponent.kt#L50 as an example how to use dagger2, but I am seeing that
dagger.android.AndroidInjector.Builder
is deprecated. https://google.github.io/dagger/api/latest/dagger/android/AndroidInjector.Builder.html
Prefer AndroidInjector.Factory now that components can have factories instead of builders
Has anyone tried this yet? I am struggling to find an example of this.
t

tseisel

04/20/2019, 2:59 PM
I just replaced
@Component.Builder abstract class Builder : AndroidInjector.Builder<AppComponent>()
by
@Component.Factory interface Factory : AndroidInjector.Factory<AppComponent>
and everything worked the same. You should also change
DaggerAppComponent.builder().create(this)
to
DaggerAppComponent.factory().create(this)
in
MainApplication
.
👍 1
d

Damien O'Reilly

04/20/2019, 3:12 PM
Oh wow, I will try that, not sure why I missed the
DaggerAppComponent.factory()
part