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
With androidx, the classic support libraries no longer work.
Simple solution is to use following code
In your build.gradle
file
android{
...
...
defaultConfig {
...
...
multiDexEnabled true
}
...
}
dependencies {
...
...
implementation 'androidx.multidex:multidex:2.0.1'
}
And in your manifest just add name attribute to the application tag
<manifest ...>
<application
android:name="androidx.multidex.MultiDexApplication"
...
...>
...
...
</application>
</manifest>
If your application is targeting API 21 or above multidex is enables by default.
Now if you want to get rid of many of the issues you face trying to support multidex - first try using code shrinking by setting minifyEnabled true
.
just adding this snipped in the build.gradle also works fine
android {
compileSdkVersion 22
buildToolsVersion "23.0.0"
defaultConfig {
minSdkVersion 14 //lower than 14 doesn't support multidex
targetSdkVersion 22
**// Enabling multidex support.
**multiDexEnabled true****
}
}