Error:Cannot fit requested classes in a single dex file.Try supplying a main-dex list. # methods: 72477 > 65536 Error:Cannot fit requested classes in a single dex file.Try supplying a main-dex list. # methods: 72477 > 65536 android android

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


None of the answers they gave you was exhaustive.The problem lies in the Multidex.You must add the library in the app gradle :

implementation 'com.android.support:multidex:1.0.3'

After, add in the defaultConfig of the app gradle :

multiDexEnabled true

Your Application must be of the Multidex type..You must write it in the manifest :

android:name=".MyApplication"

"MyApplication" must be either the Multidex class, or it must extend it.


I fixed my problem with the solution below:

In Gradle build file, add dependency:

implementation 'com.android.support:multidex:1.0.3'

And then in the "defaultConfig" section, add:

multiDexEnabled true


modify your app's or module's build.gradle

android {    defaultConfig {        ...        minSdkVersion 21 <----- *here        targetSdkVersion 26        multiDexEnabled true <------ *here    }    ...}

According to official documentation

Multidex support for Android 5.0 and higher

Android 5.0 (API level 21)and higher uses a runtime called ART which natively supports loadingmultiple DEX files from APK files. ART performs pre-compilation at appinstall time which scans for classesN.dex files and compiles them intoa single .oat file for execution by the Android device. Therefore, ifyour minSdkVersion is 21 or higher, you do not need the multidexsupport library.

For more information on the Android 5.0 runtime, read ART and Dalvik.

https://developer.android.com/studio/build/multidex