Mes
Mes

Reputation: 1691

Enable Multidex

I used to receive DexIndexOverflowException a couple of days ago and what I did is :

a) adding multiDexEnabled true to defaultConfig in my build.gradle file.

b) adding compile 'com.android.support:multidex:1.0.1' in the dependencies section.

and after that everything is running OK again.

Today I was reading multidex user guide in d.android.com site ( link here ) and it says that I should also override MultiDexApplication class (since I already extend from Application ).

My question is : since I'm not extending MultiDexApplication how is it possible, by doing only the two things I mentioned above, not to receive the Exception I was receiving before ? And what should I do now ? Should I try and extend MultiDexApplication even if now everything is OK?

Upvotes: 1

Views: 1608

Answers (1)

betorcs
betorcs

Reputation: 2831

Your code must be near in the number limit of methods, i recomend make the total implementation. Otherwise you can review your dependencies and remove those you are not using and use ProGuard. Good pratice is helpfull, like prefer use methods private when possible.

You have some possibilities to use MultiDex.

Minimal MultiDex capable application. To use the legacy multidex library there is 3 possibility:

  • Declare this class as the application in your AndroidManifest.xml.
  • Have your Application extends this class.
  • Have your Application override attachBaseContext starting with protected void attachBaseContext(Context base) { super.attachBaseContext(base); MultiDex.install(this);

The last one should fit for you.

Upvotes: 1

Related Questions