DexArchiveMergerException: Unable to merge dex

◇◆丶佛笑我妖孽 提交于 2020-01-11 03:53:06

问题


Just after updating Android studio 3.0 yesterday from 2.3.3 version, I am facing issue related to DexMergerException.

Someone else also posted question-related to this. But in this question, I want to analyze the stack trace to find the related solution(since i am newbiew here..).

I am unable to resolve it even after excluding group that might be using it. Since I am not aware of which component colliding with HttpCore so I'd use this code to exclude httpCore:

implementation ('com.android.volley:volley:1.0.0') {
        exclude group: 'org.apache.httpcomponents'
  }

Please check the Terminal logcat that would be useful to figure out the root issue:

   D:\Office_Work\Android\MnE App>gradlew build --stacktrace
Starting a Gradle Daemon, 2 incompatible and 9 stopped Daemons could not be reused, use --status for details

> Task :app:compileDebugJavaWithJavac
Note: D:\Office_Work\Android\MnE App\app\src\main\java\com\mindtree\igxbridge\measurementandevaluation\util\ConnectionUtils.java uses or overrides a deprecated AP
I.
Note: Recompile with -Xlint:deprecation for details.
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.


FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:transformClassesWithMultidexlistForDebug'.
> java.io.IOException: Can't write [D:\Office_Work\Android\MnE App\app\build\intermediates\multi-dex\debug\componentClasses.jar] (Can't read [C:\Users\m1040033\.g
radle\caches\modules-2\files-2.1\org.apache.httpcomponents\httpcore\4.3.2\31fbbff1ddbf98f3aa7377c94d33b0447c646b6e\httpcore-4.3.2.jar(;;;;;;**.class)] (Duplicate
zip entry [httpcore-4.3.2.jar:org/apache/http/annotation/NotThreadSafe.class]))

* Try:
Run with --info or --debug option to get more log output.

* Exception is:
org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':app:transformClassesWithMultidexlistForDebug'.
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:100)
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:70)
        at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:63)
        at org.gradle.api.internal.tasks.execution.ResolveTaskOutputCachingStateExecuter.execute(ResolveTaskOutputCachingStateExecuter.java:54)
        at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:58)
        at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:88)
        at org.gradle.api.internal.tasks.execution.ResolveTaskArtifactStateTaskExecuter.execute(ResolveTaskArtifactStateTaskExecuter.java:52)
        at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:52)
        at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:54)
        at org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter.execute(ExecuteAtMostOnceTaskExecuter.java:43)
        at org.gradle.api.internal.tasks.execution.CatchExceptionTaskExecuter.execute(CatchExceptionTaskExecuter.java:34)
        at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker$1.run(DefaultTaskGraphExecuter.java:248)
        at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:336)
        at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:328)
        at org.gradle.internal.progress.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:197)
        at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:107)
        at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:241)
        at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:230)
        at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.processTask(DefaultTaskPlanExecutor.java:124)
        at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.access$200(DefaultTaskPlanExecutor.java:80)
        at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker$1.execute(DefaultTaskPlanExecutor.java:105)
        at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker$1.execute(DefaultTaskPlanExecutor.java:99)
        at org.gradle.execution.taskgraph.DefaultTaskExecutionPlan.execute(DefaultTaskExecutionPlan.java:625)
        at org.gradle.execution.taskgraph.DefaultTaskExecutionPlan.executeWithTask(DefaultTaskExecutionPlan.java:580)
        at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.run(DefaultTaskPlanExecutor.java:99)
        at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:63)
        at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:46)
        at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:55)
Caused by: java.lang.RuntimeException: java.io.IOException: Can't write [D:\Office_Work\Android\MnE App\app\build\intermediates\multi-dex\debug\componentClasses.j
ar] (Can't read [C:\Users\m1040033\.gradle\caches\modules-2\files-2.1\org.apache.httpcomponents\httpcore\4.3.2\31fbbff1ddbf98f3aa7377c94d33b0447c646b6e\httpcore-4
.3.2.jar(;;;;;;**.class)] (Duplicate zip entry [httpcore-4.3.2.jar:org/apache/http/annotation/NotThreadSafe.class]))
        at com.android.builder.profile.Recorder$Block.handleException(Recorder.java:55)
        at com.android.builder.profile.ThreadRecorder.record(ThreadRecorder.java:104)
        at com.android.build.gradle.internal.pipeline.TransformTask.transform(TransformTask.java:213)
        at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:73)
        at org.gradle.api.internal.project.taskfactory.DefaultTaskClassInfoStore$IncrementalTaskAction.doExecute(DefaultTaskClassInfoStore.java:173)
        at org.gradle.api.internal.project.taskfactory.DefaultTaskClassInfoStore$StandardTaskAction.execute(DefaultTaskClassInfoStore.java:134)
        at org.gradle.api.internal.project.taskfactory.DefaultTaskClassInfoStore$StandardTaskAction.execute(DefaultTaskClassInfoStore.java:121)
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter$1.run(ExecuteActionsTaskExecuter.java:122)
        at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:336)
        at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:328)
        at org.gradle.internal.progress.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:197)
        at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:107)
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:111)
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:92)
        ... 27 more
Caused by: java.io.IOException: Can't write [D:\Office_Work\Android\MnE App\app\build\intermediates\multi-dex\debug\componentClasses.jar] (Can't read [C:\Users\m1
040033\.gradle\caches\modules-2\files-2.1\org.apache.httpcomponents\httpcore\4.3.2\31fbbff1ddbf98f3aa7377c94d33b0447c646b6e\httpcore-4.3.2.jar(;;;;;;**.class)] (D
uplicate zip entry [httpcore-4.3.2.jar:org/apache/http/annotation/NotThreadSafe.class]))
        at proguard.OutputWriter.writeOutput(OutputWriter.java:187)
        at proguard.OutputWriter.execute(OutputWriter.java:79)
        at proguard.ProGuard.writeOutput(ProGuard.java:427)
        at proguard.ProGuard.execute(ProGuard.java:175)
        at com.android.build.gradle.internal.transforms.BaseProguardAction.runProguard(BaseProguardAction.java:61)
        at com.android.build.gradle.internal.transforms.MainDexListTransform.shrinkWithProguard(MainDexListTransform.java:232)
        at com.android.build.gradle.internal.transforms.MainDexListTransform.transform(MainDexListTransform.java:184)
        at com.android.build.gradle.internal.pipeline.TransformTask$2.call(TransformTask.java:222)
        at com.android.build.gradle.internal.pipeline.TransformTask$2.call(TransformTask.java:218)
        at com.android.builder.profile.ThreadRecorder.record(ThreadRecorder.java:102)
        ... 39 more
Caused by: java.io.IOException: Can't read [C:\Users\m1040033\.gradle\caches\modules-2\files-2.1\org.apache.httpcomponents\httpcore\4.3.2\31fbbff1ddbf98f3aa7377c9
4d33b0447c646b6e\httpcore-4.3.2.jar(;;;;;;**.class)] (Duplicate zip entry [httpcore-4.3.2.jar:org/apache/http/annotation/NotThreadSafe.class])
        at proguard.InputReader.readInput(InputReader.java:188)
        at proguard.InputReader.readInput(InputReader.java:158)
        at proguard.OutputWriter.writeOutput(OutputWriter.java:176)
        ... 48 more
Caused by: java.io.IOException: Duplicate zip entry [httpcore-4.3.2.jar:org/apache/http/annotation/NotThreadSafe.class]
        at proguard.io.JarWriter.getOutputStream(JarWriter.java:138)
        at proguard.io.FilteredDataEntryWriter.getOutputStream(FilteredDataEntryWriter.java:106)
        at proguard.io.FilteredDataEntryWriter.getOutputStream(FilteredDataEntryWriter.java:106)
        at proguard.io.FilteredDataEntryWriter.getOutputStream(FilteredDataEntryWriter.java:92)
        at proguard.io.ClassRewriter.read(ClassRewriter.java:68)
        at proguard.io.FilteredDataEntryReader.read(FilteredDataEntryReader.java:87)
        at proguard.io.FilteredDataEntryReader.read(FilteredDataEntryReader.java:87)
        at proguard.io.FilteredDataEntryReader.read(FilteredDataEntryReader.java:87)
        at proguard.io.JarReader.read(JarReader.java:65)
        at proguard.io.DirectoryPump.readFiles(DirectoryPump.java:65)
        at proguard.io.DirectoryPump.pumpDataEntries(DirectoryPump.java:53)
        at proguard.InputReader.readInput(InputReader.java:184)
        ... 50 more

I just need a little hint to find out which component to exclude in gradle file.

Thanks.


回答1:


After looking for a lot of options around the internet. I figured out to include a configuration tag inside build.gradle to exclude HttpCore :

configurations {    
    all*.exclude group: 'org.apache.httpcomponents', module:'httpclient'
}

Hope it will help others.

Thanks.



来源:https://stackoverflow.com/questions/46976279/dexarchivemergerexception-unable-to-merge-dex

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!