Unity: All versions | Appodeal SDK: All versions


The error "Cannot fit requested classes in a single dex file" happens if the number of method references exceed the 65K reference limit.

The error example from Unity Editor Log:

stderr[
D8: Cannot fit requested classes in a single dex file (# methods: 136481 > 65536)

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':launcher:transformDexArchiveWithExternalLibsDexMergerForRelease'.
> com.android.builder.dexing.DexArchiveMergerException: Error while merging dex archives:
The number of method references in a .dex file cannot exceed 64K.
Learn how to resolve this issue at https://developer.android.com/tools/building/multidex.html

To solve the error enable Multidex support.

For Unity 2019.2 and versions below:

Add Multidex support to your project. Follow this guide to add Multidex.

For Unity 2019.3 or higher:

Go to File Build settings Player Settings Player Minimum API level and set up minimum API level to 21 or higher, where Multidex is enabled by default.