Hello Guys How are you all? Hope You all are fine. When I was trying to run my flutter app and suddenly I get the following error in my stack track. Execution failed for task ‘:app:mergeDexDebug’ in flutter. So today Here I come with all possible solutions for this error.
We are providing you all possible solutions to solve this error. let’s start this article without wasting your time.
How Execution failed for task ‘:app:mergeDexDebug’ Error Occurs ?
I have run my app after setup Firestore plugin and also added google-service.json file. But when I run my app I get following error in my stacktrack:
FAILURE: Build failed with an exception.
What went wrong: 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: 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
How to Solve Execution failed for task ‘:app:mergeDexDebug’ Error?
- How to Solve Execution failed for task ':app:mergeDexDebug' Error?
To solve Execution failed for task ':app:mergeDexDebug' you just need to enable multidex. Open your build.gradle which is located at android/app/build.gradle. and add below two line in your build.gradle file. then Just uninstall your app and run flutter clean and then flutter run will resolve your error.
- Execution failed for task ':app:mergeDexDebug'
To solve Execution failed for task ':app:mergeDexDebug' you just need to enable multidex. Open your build.gradle which is located at android/app/build.gradle. and add below two line in your build.gradle file. then Just uninstall your app and run flutter clean and then flutter run will resolve your error.
Solution 1
Actually this problem is happened while you have imported a lot of packages in your yaml file which cannot fit into a single .dex built so that you have to enable multidex.
Open your build.gradle which is located at android/app/build.gradle. and add below two line in your build.gradle file.
dependencies {
implementation 'com.android.support:multidex:1.0.3' //enter the latest version
}
android {
defaultConfig {
multiDexEnabled true
}
}
Just uninstall your app and run flutter clean and then flutter run will resolve your error.
Solution 2
If you are using AndroidX,
Add below lines to android/app/build.gradle
multiDexEnabled true // in the defaultConfig {}
implementation 'androidx.multidex:multidex:2.0.1' // in the dependencies
add this line in the AndroidManifest.xml
<application
android:name="androidx.multidex.MultiDexApplication"
Summery
So, It’s All About This Error. I hope this tutorial helps you to Solve your error. Please Comment Below if You stucks anywhere with my code. And please comment below which solution worked for you. Thank You.
Also Check Out Below Tutorials
- Waiting for another flutter command to release the startup lock
- Scaffold.of() called with a context that does not contain a Scaffold
- Flutter Error: RangeError (index): Invalid value: Not in range 0..2, inclusive: 3
- How to solve SocketException: Failed host lookup: ‘flutter-project-xxxxx.firebaseio.com’ (OS Error: No address associated with hostname, errno = 7)
- Flutter BottomNavigationBar not working with more than three items
Leave a Reply