Android Studio Rebuild DexArchiveMergerException Unable To Merge Dex

When you build an android project in android studio, you may encounter DexArchiveMergerException unable to merge dex exception. The detailed error message is as below.

Error:Execution failed for task ':app:transformDexArchiveWithExternalLibsDexMergerForDebug'.
> java.lang.RuntimeException: com.android.builder.dexing.DexArchiveMergerException: Unable to merge dex

If you still can not fix this error after struggle for taking some actions such as clean the project, even restart the android studio, you need to look at the error messages carefully.

In my environment, I finally resolve the above error by changing the dependencies library version in the android studio left panel Gradle Scripts —> build.gradle( Module: app) file follows the below steps.

1. How To Fix The DexArchiveMergerException Unable To Merge Dex Exception.

  1. Double click the Gradle Scripts —> build.gradle( Module: app) file in the android studio left panel to open it.
  2. Look at each warning message in the right panel build gradle content carefully to know the reason for the error.
    change-dependency-lib-version-in-module-app-build-gradle-file
  3. In my build.gradle I found the warning message is that This support library should not use a different version (26) than the compileSdkVersion (27) for the dependency library ‘com.android.support:design:26.1.0’.
  4. So I change the version to ‘com.android.support:design:27.1.0’.
  5. After changing the version, click the Sync Now at the top right corner and rebuild the project again, you will find the error has been fixed.
  6. Conclusion: When you encounter a build error in android studio, you had better look at the build.gradle file content carefully. Especially for the dependencies library with warning messages. Such errors occurred usually because of dependency library version mismatch.

Leave a Comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.