- Home /
DexArchiveMergerException: Unable to merge dex
I've tried implementing unity Admob but then upon implementing the game I get error describing about Dex Archive Merger
CommandInvokationFailure: Gradle build failed.
C:/Program Files/Java/jdk1.8.0_161\bin\java.exe -classpath "C:\Program Files\Unity\Editor\Data\PlaybackEngines\AndroidPlayer\Tools\gradle\lib\gradle-launcher-4.2.1.jar" org.gradle.launcher.GradleMain "-Dorg.gradle.jvmargs=-Xmx2048m" "assembleDebug"
stderr[
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':transformDexArchiveWithExternalLibsDexMergerForDebug'.
> java.lang.RuntimeException: java.lang.RuntimeException: com.android.builder.dexing.DexArchiveMergerException: Unable to merge dex
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
* Get more help at https://help.gradle.org
BUILD FAILED in 43s
]
stdout[
:preBuild UP-TO-DATE
:preDebugBuild
:compileDebugAidl
:compileDebugRenderscript
:checkDebugManifest
:generateDebugBuildConfig
:prepareLintJar
:generateDebugResValues
:generateDebugResources
:mergeDebugResources
:createDebugCompatibleScreenManifests
:processDebugManifest
:splitsDiscoveryTaskDebug
:processDebugResources
:generateDebugSources
:javaPreCompileDebug
:compileDebugJavaWithJavac
:compileDebugNdk NO-SOURCE
:compileDebugSources
:mergeDebugShaders
:compileDebugShaders
:generateDebugAssets
:mergeDebugAssets
:transformClassesWithDexBuilderForDebug
:transformDexArchiveWithExternalLibsDexMergerForDebug FAILED
19 actionable tasks: 19 executed
]
exit code: 1
UnityEditor.Android.Command.WaitForProgramToRun (UnityEditor.Utils.Program p, UnityEditor.Android.WaitingForProcessToExit waitingForProcessToExit, System.String errorMsg)
UnityEditor.Android.Command.Run (System.Diagnostics.ProcessStartInfo psi, UnityEditor.Android.WaitingForProcessToExit waitingForProcessToExit, System.String errorMsg)
UnityEditor.Android.AndroidJavaTools.RunJava (System.String args, System.String workingdir, System.Action`1 progress, System.String error)
UnityEditor.Android.GradleWrapper.Run (UnityEditor.Android.AndroidJavaTools javaTools, System.String workingdir, System.String task, System.Action`1 progress)
Rethrow as GradleInvokationException: Gradle build failed
UnityEditor.Android.GradleWrapper.Run (UnityEditor.Android.AndroidJavaTools javaTools, System.String workingdir, System.String task, System.Action`1 progress)
UnityEditor.Android.PostProcessor.Tasks.BuildGradleProject.Execute (UnityEditor.Android.PostProcessor.PostProcessorContext context)
UnityEditor.Android.PostProcessor.PostProcessRunner.RunAllTasks (UnityEditor.Android.PostProcessor.PostProcessorContext context)
UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr)
How do I resolve this kind of issue?
Answer by Morgun71 · Jun 23, 2020 at 09:43 PM
Looks like if you change Minimum API Level to Android 5.0 it can help with this issue. (it has some other multidex settings). This helped me.
Answer by nextage575 · Jul 29, 2020 at 06:33 AM
Go to build player settings-->Publishing settings and set Release to dropdown Gradle experimental and hit build,worked for me.
Answer by k3nz1e · May 07, 2019 at 02:56 AM
I was able to fix this by going through my plugin folders and finding duplicates.
@k3nz1e What do you mean by duplicates? Since a file name can't be in the same folder more than once, what qualifies as a duplicate?
I've been stuck on this for a day
@seanbiganski So for instance in one plugins folder i had a plugin called com.android.support.support.annotation-26.1.0.jar and after importing another package i had another plugins folder with support-annotations-26.1.0.jar in it. Same file just duplicated and different name. Deleting one of these solved my issue.
Hey I just wanted to follow and say you were right. I was not finding the duplicate files initially because the na$$anonymous$$g convention was changed. In my case, $$anonymous$$apbox was using the file name "support-compat-25.1.0" for example and Firebase was using "com.android.support-compat-26.1.0". Thanks again.
Answer by pwangweb · Nov 29, 2018 at 06:05 PM
I also encountered the same problem. The release build is fine though. Did you find a fix?,I have encountered the same problem. Did you find a solution?
It seems that you cant fix this once this happens to your app the best thing to do is to delete the SD$$anonymous$$ that causes this error and find a newer version/alternative of that. (also you should've have made a backup before installing an SD$$anonymous$$)
I am facing the same exact problem from what I read I understood that there are two different versions of the same library but I can't figure out what library or SD$$anonymous$$ is causing the problem is there a way to do that?
Open the Package $$anonymous$$anager window from window tab. Click the "In Project" button if you are in "All packages" mode. Select the package you want to remove from the Packages list. The package information appears in the Details pane. Click the Remove button.
Your answer
Follow this Question
Related Questions
Error Building Android Project 2 Answers
Help with error: UnassignedReferenceException 5 Answers