Fix Issue : Execution failed for task ':app:mergeDexDebug' (Error while merging dex archives)

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

com.android.builder.dexing.DexArchiveMergerException: Error while merging dex archives:
The number of method references in a .dex file cannot exceed 64K.

If you are working on a flutter application and if you get these types of error.



Execution failed for task ':app:mergeDexDebug'.

A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
com.android.builder.dexing.DexArchiveMergerException: Error while merging dex archives:

Solution of these issues:

Enable multidex for apps with over 64K methods


Step 1: Open File in your project your_project>Android>app/build.gradle

Step 2: Modify the module-level build.gradle file to enable multidex and add the multidex library as a dependency, as shown here:

android {
    defaultConfig {
        ...
        minSdkVersion 15
        targetSdkVersion 28
        multiDexEnabled true
    }
    ...
}

dependencies {
  implementation 'com.android.support:multidex:1.0.3'
}



Why showing this issue in Application

When you are working with compileSdkVersion above 21 then need to add implementation 'com.android.support:multidex:1.0.3' a dependency. After your app gets started.

Previous
Next Post »