I want to use the new Multidex support library to break the method limit for one of my apps.
With Android Lollipop Google introduced a multidex support library that makes it easy to multidex.
What steps are needed to use this library and to build my app with multidex support?
Edit:
Android 5.0 (API level 21) and higher uses ART which natively supports multidexing. Therefore, if your
minSdkVersion
is 21 or higher, the multidex support library is not needed.Modify your
build.gradle
:If you are running unit tests, you will want to include this in your
Application
class:For more info, this is a good guide.
Add to AndroidManifest.xml:
OR
in your custom Application's attachBaseContext method
or your custom Application extend MultiDexApplication
add multiDexEnabled = true in your build.gradle
SIMPLY, in order to enable multidex, you need to ...
also you must change your manifest file. In your manifest add the MultiDexApplication class from the multidex support library to the application element like this
If you want to enable multi-dex in your project then just go to gradle.builder
and add this in your dependencie
then you have to add
Then open a class and extand it to Application If your app uses extends the Application class, you can override the oncrete() method and call
to enable multidex.
and finally add into your manifest
just adding this snipped in the build.gradle also works fine
First you should try with Proguard (This clean all code unused)