Dagger: Add support for MultiDexApplication

Created on 17 Jan 2018  Â·  7Comments  Â·  Source: google/dagger

Please add support for MultiDexApplication in DaggerApplication. This would only require extending from MultiDexApplication instead of Application. Or is there a good way to use this that I'm not aware of?

Most helpful comment

@JakeWharton is right, but what is likely to be even smaller (and even less likely to change) is to keep the DaggerApplication base class and copy the contents of the MultidexApplication implementation. This is a documented approach by the MultidexApplication docs

All 7 comments

You can copy the implementation of DaggerApplication directly into your Application subclass. It's only a few lines.

Thanks for your response. I hope I'm correct in assuming that a) the implementation for DaggerApplication is not likely to change and b) you (edit: or whoever calls the shots) are not going to consider supporting MultiDexApplication?

I don't speak for the Dagger team, but the documentation indicates that these base classes are merely provided as a convenience around the supported mechanism and instructions for doing it yourself:

Because DispatchingAndroidInjector looks up the appropriate AndroidInjector.Factory by the class at runtime, a base class can implement HasActivityInjector/HasFragmentInjector/etc as well as call AndroidInjection.inject(). All each subclass needs to do is bind a corresponding @Subcomponent. Dagger provides a few base types that do this

@JakeWharton is right, but what is likely to be even smaller (and even less likely to change) is to keep the DaggerApplication base class and copy the contents of the MultidexApplication implementation. This is a documented approach by the MultidexApplication docs

Wow that's tiny!

On Wed, Jan 17, 2018 at 10:26 AM Ron Shapiro notifications@github.com
wrote:

Closed #1035 https://github.com/google/dagger/issues/1035.

—
You are receiving this because you were mentioned.

Reply to this email directly, view it on GitHub
https://github.com/google/dagger/issues/1035#event-1428496743, or mute
the thread
https://github.com/notifications/unsubscribe-auth/AAEEEQx4oPmo66xQOODeQKSTyDQiNdlOks5tLhEhgaJpZM4RhdFS
.

the links you pasted are now blank. Can you check em out please @ronshapiro

@Ezike from docs if you don't have the option to extend MultidexApplication you can do this

class MyApplication : SomeOtherApplication() {

    override fun attachBaseContext(base: Context) {
        super.attachBaseContext(base)
        MultiDex.install(this)
    }
}

Docs

Was this page helpful?
0 / 5 - 0 ratings

Related issues

cesar1000 picture cesar1000  Â·  3Comments

rciovati picture rciovati  Â·  3Comments

makaroffandrey picture makaroffandrey  Â·  3Comments

SAGARSURI picture SAGARSURI  Â·  3Comments

JakeWharton picture JakeWharton  Â·  3Comments