Unable to merge dex Android - Studio 3.0 build err

2019-05-30 08:19发布

问题:

What I want to know

I have got the error to build my project after updating my Android Studio 3.0. This error said the Lorg/objectweb/asm/AnnotationWriter is duplicated. So I assume that I have to exclude the dependencies for the grade but I don't know how to find the library that uses this AnnotationWriter.

compile('com.googlecode.json-simple:json-simple:1.1.1') {
    exclude group: 'org.hamcrest', module: 'hamcrest-core'
}

I understand that there are several same posts on the StackOverflow but I still need help even though I tried almost everything that everyone commented.

Thank you.

This is what I tried

  • Build -> Clean Project.
  • Adding multiDexEnabled true(It's already added from the previous version)
  • Update the compileSdkVersion, compileSdkVersion and supportLibVersion to 26
  • Deleting .gradle and build folder then clean and Rebuild
  • Updating Google Play Services to latest version(46)
  • Added jumboMode true to dexOption in the gradle file.
  • Replace complie to implementation, testCompiple to testImplementation and testImplementation to androidTestImplementation

Stack Trace

14:57:28.124 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] 
14:57:28.124 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] FAILURE: Build failed with an exception.
14:57:28.124 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] 
14:57:28.124 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] * What went wrong:
14:57:28.124 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] Execution failed for task ':app:transformDexArchiveWithExternalLibsDexMergerForDebug'.
14:57:28.124 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] > com.android.builder.dexing.DexArchiveMergerException: Unable to merge dex
14:57:28.124 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] 
14:57:28.124 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] * Exception is:
14:57:28.124 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':app:transformDexArchiveWithExternalLibsDexMergerForDebug'.
14:57:28.124 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:100)
14:57:28.124 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:70)
14:57:28.124 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:63)
14:57:28.124 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.api.internal.tasks.execution.ResolveTaskOutputCachingStateExecuter.execute(ResolveTaskOutputCachingStateExecuter.java:54)
14:57:28.125 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:58)
14:57:28.125 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:88)
14:57:28.125 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.api.internal.tasks.execution.ResolveTaskArtifactStateTaskExecuter.execute(ResolveTaskArtifactStateTaskExecuter.java:52)
14:57:28.125 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:52)
14:57:28.125 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:54)
14:57:28.125 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter.execute(ExecuteAtMostOnceTaskExecuter.java:43)
14:57:28.125 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.api.internal.tasks.execution.CatchExceptionTaskExecuter.execute(CatchExceptionTaskExecuter.java:34)
14:57:28.125 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker$1.run(DefaultTaskGraphExecuter.java:248)
14:57:28.125 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:336)
14:57:28.125 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:328)
14:57:28.125 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.internal.progress.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:197)
14:57:28.125 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:107)
14:57:28.126 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:241)
14:57:28.126 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:230)
14:57:28.126 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.processTask(DefaultTaskPlanExecutor.java:124)
14:57:28.126 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.access$200(DefaultTaskPlanExecutor.java:80)
14:57:28.126 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker$1.execute(DefaultTaskPlanExecutor.java:105)
14:57:28.126 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker$1.execute(DefaultTaskPlanExecutor.java:99)
14:57:28.126 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.execution.taskgraph.DefaultTaskExecutionPlan.execute(DefaultTaskExecutionPlan.java:625)
14:57:28.126 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.execution.taskgraph.DefaultTaskExecutionPlan.executeWithTask(DefaultTaskExecutionPlan.java:580)
14:57:28.126 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.run(DefaultTaskPlanExecutor.java:99)
14:57:28.126 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:63)
14:57:28.126 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:46)
14:57:28.126 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:55)
14:57:28.126 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] Caused by: java.lang.RuntimeException: com.android.builder.dexing.DexArchiveMergerException: Unable to merge dex
14:57:28.126 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at com.android.builder.dexing.DxDexArchiveMerger.mergeMultidex(DxDexArchiveMerger.java:266)
14:57:28.126 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at com.android.builder.dexing.DxDexArchiveMerger.mergeDexArchives(DxDexArchiveMerger.java:133)
14:57:28.126 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at com.android.build.gradle.internal.transforms.DexMergerTransformCallable.call(DexMergerTransformCallable.java:97)
14:57:28.126 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at com.android.build.gradle.internal.transforms.ExternalLibsMergerTransform.transform(ExternalLibsMergerTransform.kt:121)
14:57:28.127 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at com.android.build.gradle.internal.pipeline.TransformTask$2.call(TransformTask.java:222)
14:57:28.127 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at com.android.build.gradle.internal.pipeline.TransformTask$2.call(TransformTask.java:218)
14:57:28.127 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at com.android.builder.profile.ThreadRecorder.record(ThreadRecorder.java:102)
14:57:28.127 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at com.android.build.gradle.internal.pipeline.TransformTask.transform(TransformTask.java:213)
14:57:28.127 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:73)
14:57:28.127 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.api.internal.project.taskfactory.DefaultTaskClassInfoStore$IncrementalTaskAction.doExecute(DefaultTaskClassInfoStore.java:173)
14:57:28.127 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.api.internal.project.taskfactory.DefaultTaskClassInfoStore$StandardTaskAction.execute(DefaultTaskClassInfoStore.java:134)
14:57:28.127 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.api.internal.project.taskfactory.DefaultTaskClassInfoStore$StandardTaskAction.execute(DefaultTaskClassInfoStore.java:121)
14:57:28.127 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter$1.run(ExecuteActionsTaskExecuter.java:122)
14:57:28.127 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:336)
14:57:28.127 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:328)
14:57:28.127 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.internal.progress.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:197)
14:57:28.127 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:107)
14:57:28.127 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:111)
14:57:28.127 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:92)
14:57:28.127 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   ... 27 more
14:57:28.127 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] Caused by: com.android.builder.dexing.DexArchiveMergerException: Unable to merge dex
14:57:28.127 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at com.android.builder.dexing.DexArchiveMergerCallable.call(DexArchiveMergerCallable.java:72)
14:57:28.127 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at com.android.builder.dexing.DexArchiveMergerCallable.call(DexArchiveMergerCallable.java:36)
14:57:28.127 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   ... 46 more
14:57:28.127 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] Caused by: com.android.dex.DexException: Multiple dex files define Lorg/objectweb/asm/AnnotationWriter;
14:57:28.127 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at com.android.dx.merge.DexMerger.readSortableTypes(DexMerger.java:661)
14:57:28.127 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at com.android.dx.merge.DexMerger.getSortedTypes(DexMerger.java:616)
14:57:28.128 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at com.android.dx.merge.DexMerger.mergeClassDefs(DexMerger.java:598)
14:57:28.128 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:171)
14:57:28.128 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at com.android.dx.merge.DexMerger.merge(DexMerger.java:198)
14:57:28.128 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at com.android.builder.dexing.DexArchiveMergerCallable.call(DexArchiveMergerCallable.java:61)
14:57:28.128 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   ... 47 more
14:57:28.128 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] 
14:57:28.128 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] 
14:57:28.128 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] * Get more help at https://help.gradle.org
14:57:28.128 [ERROR] [org.gradle.internal.buildevents.BuildResultLogger] 
14:57:28.128 [ERROR] [org.gradle.internal.buildevents.BuildResultLogger] BUILD FAILED in 3s

Dependencies tree

debugRuntimeClasspath - Resolved configuration for runtime for variant: debug
    +--- org.jacoco:org.jacoco.agent:0.7.4.201502262128
    +--- com.android.support:design:26.0.2
    |    +--- com.android.support:support-v4:26.0.2
    |    |    +--- com.android.support:support-compat:26.0.2
    |    |    |    \--- com.android.support:support-annotations:26.0.2 -> 26.1.0
    |    |    +--- com.android.support:support-media-compat:26.0.2
    |    |    |    +--- com.android.support:support-annotations:26.0.2 -> 26.1.0
    |    |    |    \--- com.android.support:support-compat:26.0.2 (*)
    |    |    +--- com.android.support:support-core-utils:26.0.2
    |    |    |    +--- com.android.support:support-annotations:26.0.2 -> 26.1.0
    |    |    |    \--- com.android.support:support-compat:26.0.2 (*)
    |    |    +--- com.android.support:support-core-ui:26.0.2
    |    |    |    +--- com.android.support:support-annotations:26.0.2 -> 26.1.0
    |    |    |    \--- com.android.support:support-compat:26.0.2 (*)
    |    |    \--- com.android.support:support-fragment:26.0.2
    |    |         +--- com.android.support:support-compat:26.0.2 (*)
    |    |         +--- com.android.support:support-core-ui:26.0.2 (*)
    |    |         \--- com.android.support:support-core-utils:26.0.2 (*)
    |    +--- com.android.support:appcompat-v7:26.0.2
    |    |    +--- com.android.support:support-annotations:26.0.2 -> 26.1.0
    |    |    +--- com.android.support:support-v4:26.0.2 (*)
    |    |    +--- com.android.support:support-vector-drawable:26.0.2
    |    |    |    +--- com.android.support:support-annotations:26.0.2 -> 26.1.0
    |    |    |    \--- com.android.support:support-compat:26.0.2 (*)
    |    |    \--- com.android.support:animated-vector-drawable:26.0.2
    |    |         +--- com.android.support:support-vector-drawable:26.0.2 (*)
    |    |         \--- com.android.support:support-core-ui:26.0.2 (*)
    |    +--- com.android.support:recyclerview-v7:26.0.2
    |    |    +--- com.android.support:support-annotations:26.0.2 -> 26.1.0
    |    |    +--- com.android.support:support-compat:26.0.2 (*)
    |    |    \--- com.android.support:support-core-ui:26.0.2 (*)
    |    \--- com.android.support:transition:26.0.2
    |         +--- com.android.support:support-annotations:26.0.2 -> 26.1.0
    |         \--- com.android.support:support-v4:26.0.2 (*)
    +--- com.android.support:appcompat-v7:26.0.2 (*)
    +--- com.squareup.retrofit2:retrofit:2.3.0
    |    \--- com.squareup.okhttp3:okhttp:3.8.0
    |         \--- com.squareup.okio:okio:1.13.0
    +--- com.squareup.retrofit2:retrofit-mock:2.3.0
    |    \--- com.squareup.retrofit2:retrofit:2.3.0 (*)
    +--- com.squareup.retrofit2:converter-gson:2.3.0
    |    +--- com.squareup.retrofit2:retrofit:2.3.0 (*)
    |    \--- com.google.code.gson:gson:2.7 -> 2.8.2
    +--- com.squareup.retrofit2:adapter-rxjava:2.3.0
    |    +--- com.squareup.retrofit2:retrofit:2.3.0 (*)
    |    \--- io.reactivex:rxjava:1.3.0
    +--- com.squareup.okhttp3:logging-interceptor:3.8.0
    |    \--- com.squareup.okhttp3:okhttp:3.8.0 (*)
    +--- io.reactivex:rxandroid:1.2.1
    |    \--- io.reactivex:rxjava:1.1.6 -> 1.3.0
    +--- io.reactivex:rxjava:1.1.6 -> 1.3.0
    +--- com.trello:rxlifecycle:1.0
    |    +--- io.reactivex:rxjava:1.2.1 -> 1.3.0
    |    \--- com.google.code.findbugs:jsr305:3.0.1
    +--- com.trello:rxlifecycle-android:1.0
    |    +--- com.trello:rxlifecycle:1.0 (*)
    |    \--- com.jakewharton.rxbinding:rxbinding:0.4.0
    |         +--- io.reactivex:rxandroid:1.1.0 -> 1.2.1 (*)
    |         +--- io.reactivex:rxjava:1.1.0 -> 1.3.0
    |         \--- com.android.support:support-annotations:23.1.0 -> 26.1.0
    +--- com.trello:rxlifecycle-components:1.0
    |    +--- com.trello:rxlifecycle-android:1.0 (*)
    |    +--- io.reactivex:rxjava:1.2.1 -> 1.3.0
    |    \--- com.android.support:appcompat-v7:25.0.0 -> 26.0.2 (*)
    +--- com.google.guava:guava:20.0
    +--- com.google.code.gson:gson:2.8.2
    +--- com.jayway.jsonpath:json-path:2.0.0
    |    +--- org.slf4j:slf4j-api:1.7.10
    |    \--- net.minidev:json-smart:2.1.1
    |         \--- net.minidev:asm:1.0.2
    |              \--- asm:asm:3.3.1
    +--- me.dm7.barcodescanner:zxing:1.9.8
    |    +--- me.dm7.barcodescanner:core:1.9.8
    |    |    \--- com.android.support:support-v4:25.3.1 -> 26.0.2 (*)
    |    \--- com.google.zxing:core:3.3.0
    +--- com.twilio:video-android:1.3.4
    |    +--- com.android.support:support-annotations:26.1.0
    |    \--- com.getkeepsafe.relinker:relinker:1.2.2
    +--- com.wang.avi:library:2.1.3
    +--- uk.co.chrisjenx:calligraphy:2.3.0
    |    \--- com.android.support:appcompat-v7:25.3.1 -> 26.0.2 (*)
    +--- com.jakewharton:butterknife:8.8.1
    |    +--- com.jakewharton:butterknife-annotations:8.8.1
    |    |    \--- com.android.support:support-annotations:25.3.0 -> 26.1.0
    |    +--- com.android.support:support-annotations:25.3.0 -> 26.1.0
    |    \--- com.android.support:support-compat:25.3.0 -> 26.0.2 (*)
    +--- com.daimajia.easing:library:2.1
    |    \--- com.android.support:appcompat-v7:25.1.1 -> 26.0.2 (*)
    +--- com.daimajia.androidanimations:library:2.3
    +--- com.microsoft.azure.mobile:mobile-center-analytics:0.12.0
    |    \--- com.microsoft.azure.mobile:mobile-center:0.12.0
    +--- com.microsoft.azure.mobile:mobile-center-crashes:0.12.0
    |    \--- com.microsoft.azure.mobile:mobile-center:0.12.0
    \--- net.danlew:android.joda:2.9.9
         \--- joda-time:joda-time:2.9.9

回答1:

Finally, I figured this out with below.

compile('com.jayway.jsonpath:json-path:2.0.0') {
exclude group: 'net.minidev', module: 'asm'
}