MultiDex
Question
MultiDex
Short interview answer
MultiDex lets an Android app use multiple DEX files when it exceeds a single DEX file’s 65,536-reference limit. It matters primarily for apps supporting Android versions before API 21; newer runtimes support multiple DEX files natively.
Detailed answer
First reduce unnecessary dependencies and enable release code shrinking. If the minimum SDK is 20 or lower and the limit remains, configure multidex in the release build:
android {
defaultConfig { multiDexEnabled = true }
}
dependencies { implementation("androidx.multidex:multidex:2.0.1") }
For API 21 and later, the runtime supports multiple DEX files natively. This legacy compatibility configuration can increase startup and build costs, so it is not a substitute for dependency discipline.
Glossary
- DEX: Dalvik Executable.