I'm an Android developer still supporting the minSdk 19 and faced an issue about the Maindex not fitting the requested classes in the main-dex file. Even after following the recommended steps at the 'Enable multidex' developers page, the error persists. What can I do to support more methods in the main-dex files, or better divide them between the files?
I have followed the steps suggested in the https://developer.android.com/studio/build/multidex page. In the Gradle file, I've implemented the 'com.android.support:multidex:1.0.3' dependency. My application extends from MultiDexApplication.
The main issue might be that the migration to the AndroidX was already made, so the application imports androidx.multidex.MultiDexApplication library instead of importing the support one, which was implemented in the dependencies.
Inside the build.gradle(Module:App) file (only the important parts are highlighted)
...
dexOptions {
jumboMode true
}
...
defaultConfig {
minSdkVersion 19
targetSdkVersion 28
...
multiDexEnabled true
multiDexKeepProguard file('multidex-config.txt')
}
...
dependencies {
...
implementation "com.android.support:multidex:1.0.3"
...
}
In the application file:
import androidx.multidex.MultiDexApplication;
...
public class MainApplication extends MultiDexApplication...
The expected was, with the attempts made, that the methods would fit in the dex files. However, the error persists when trying to build the APK:
Error: null, Cannot fit requested classes in the main-dex file (# methods: 66064 > 65536)