How to Enable Multidex for Android App
The number of methods an Android app can have is limited to 65,536 (64 * 1024). Once the limit is crossed, the app builds fail with an error that says Cannot fit requested classes in a single dex file . AGPBI: {"kind":"error","text":"Cannot fit requested classes in a single dex file (# methods: 76137 \u003e 65536)","sources":[{}],"tool":"D8"} > Task :app:transformDexArchiveWithDexMergerForDebug FAILED java.lang.RuntimeException: java.lang.RuntimeException: com.android.builder.dexing.DexArchiveMergerException: Error while merging dex archives: The number of method references in a .dex file cannot exceed 64K. To continue adding methods beyond the infamous 64k method limit, we need to enable multidex in our application. Let's get started. 1) Add the dependency to module level build.gradle file. implementation 'com.android.support:multidex:1.0.3' 2) In the same module level build.gradle ...