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
Here is an up-to-date approach as of October 2020, with Android X. This comes from Android's documentation, "Enable multidex for apps with over 64K methods."
minSdk
>= 21You do not need to do anything. All of these devices use the Android RunTime (ART) VM, which supports multidex natively.
minSdk
< 21In your module-level build.gradle
, ensure that the following configurations are populated:
android {
defaultConfig {
multiDexEnabled true
}
}
dependencies {
implementation 'androidx.multidex:multidex:2.0.1'
}
You need to install explicit multidex support. The documentation includes three methods to do so, and you have to pick one.
For example, in your src/main/AndroidManifest.xml
, you can declare MultiDexApplication
as the application:name
: