I have been following <https://github.com/google/i...
# android
d
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
I just replaced
Copy code
@Component.Builder abstract class Builder : AndroidInjector.Builder<AppComponent>()
by
Copy code
@Component.Factory interface Factory : AndroidInjector.Factory<AppComponent>
and everything worked the same. You should also change
Copy code
DaggerAppComponent.builder().create(this)
to
Copy code
DaggerAppComponent.factory().create(this)
in
MainApplication
.
👍 1
d
Oh wow, I will try that, not sure why I missed the
DaggerAppComponent.factory()
part