Search code examples
androidandroid-gradle-pluginandroid-multidex

What if I override Application and set multiDexEnabled to 'true'?


This question is based just out of curiousity. I've been playing around with MultiDexApplication and the whole multi-dex stuff. It turns out, I don't really need it in my app. I've already reverted from MultiDexApplication to Application for overriding my app class.

Just for the sake of curiousity, I tried two things:

  1. Override Application in the app class but set multiDexEnabled to true. In this case, nothing happened in the app, it seems to be running fine. Would there be a problem in a case I'm not foreseeing?
  2. Override MultiDexApplication in the app class but set multiDexEnabled to false. I'm not able to find the class MultiDexApplication in this case. Enabling multiDexEnabled again made the class available. Why can one not extend MultiDexApplication without wanting to multiDexEnabled?

Again, this question is just for the sake of curiosity. Excuse me if it was an unnecessary read for you.


Solution

    1. Your device is running at least Android 5. Art supports multi dexing natively, so you don't anything there. Run it on a device with an older version of Android. It will crash

    2. 2.

    Override MultiDexApplication in the app class but set minifyEnabled to false.

    minifyEnabled is for Proguard. It is not related with Multidex. Also, multiDexEnabled won't prevent you to extend MultiDexApplication as well. If you had this problem, then it is probably related to something else.

    Why can one not extend MultiDexApplication without wanting to multiDexEnabled?

    Why would you use something that you don't want/need? MultiDexApplication allows you to load/handle more than one dex file. If one is enough for your app, why bother in the first place?