# Error: Cannot fit requested classes in a single dex file. Try supplying a main-dex-list.

- **ID:** `android/multidex-main-dex-list-error`
- **Domain:** android
- **Category:** build_error
- **Verification:** ai_generated
- **Fix Rate:** 90%

## Root Cause

The number of methods in the app exceeds the 64K limit per dex file, and the build system cannot determine which classes must go into the primary dex.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| Android 5.0 (API 21) | active | — | — |
| Android 6.0 (API 23) | active | — | — |
| Android Gradle Plugin 7.0 | active | — | — |
| Android Gradle Plugin 8.0 | active | — | — |

## Workarounds

1. **Create a main-dex-list.txt file in the app's root directory listing classes that must be in the primary dex (e.g., Application subclass, Activity, Service). Then configure build.gradle: 'multiDexKeepProguard file('main-dex-list.txt')'.** (90% success)
   ```
   Create a main-dex-list.txt file in the app's root directory listing classes that must be in the primary dex (e.g., Application subclass, Activity, Service). Then configure build.gradle: 'multiDexKeepProguard file('main-dex-list.txt')'.
   ```
2. **Enable multidex in build.gradle: 'defaultConfig.multiDexEnabled true' and add the multidex dependency: 'implementation 'androidx.multidex:multidex:2.0.1''. For apps targeting API < 21, ensure the Application class extends MultiDexApplication.** (85% success)
   ```
   Enable multidex in build.gradle: 'defaultConfig.multiDexEnabled true' and add the multidex dependency: 'implementation 'androidx.multidex:multidex:2.0.1''. For apps targeting API < 21, ensure the Application class extends MultiDexApplication.
   ```
3. **Use ProGuard or R8 to shrink the code and remove unused methods, reducing the overall method count below the 64K limit.** (80% success)
   ```
   Use ProGuard or R8 to shrink the code and remove unused methods, reducing the overall method count below the 64K limit.
   ```

## Dead Ends

- **** — For apps with very large method counts, automatic resolution may fail if certain classes must be in the primary dex for startup. (60% fail)
- **** — This is an extreme measure that breaks functionality; the real fix is proper multidex configuration. (90% fail)
