DexArchiveMergerException Program type already present: a.a.a

Viewed 3081

I am getting this exception:

AGPBI: {"kind":"error","text":"Program type already present: a.a.a","sources":[{}],"tool":"D8"} com.android.builder.dexing.DexArchiveMergerException: Error while merging dex archives: Learn how to resolve the issue at https://developer.android.com/studio/build/dependencies#duplicate_classes. Program type already present: a.a.a at com.android.builder.dexing.D8DexArchiveMerger.getExceptionToRethrow(D8DexArchiveMerger.java:131) at com.android.builder.dexing.D8DexArchiveMerger.mergeDexArchives(D8DexArchiveMerger.java:118) at com.android.build.gradle.internal.transforms.DexMergerTransformCallable.call(DexMergerTransformCallable.java:102) at com.android.build.gradle.internal.tasks.DexMergingTaskRunnable.run(DexMergingTask.kt:444) at com.android.build.gradle.internal.tasks.Workers$ActionFacade.run(Workers.kt:335) at org.gradle.workers.internal.DefaultWorkerServer.execute(DefaultWorkerServer.java:39) at org.gradle.workers.internal.NoIsolationWorkerFactory$1$1.execute(NoIsolationWorkerFactory.java:61) at org.gradle.workers.internal.AbstractWorker$1.call(AbstractWorker.java:44) at org.gradle.workers.internal.AbstractWorker$1.call(AbstractWorker.java:41) at org.gradle.internal.operations.DefaultBuildOperationExecutor$CallableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:416) at org.gradle.internal.operations.DefaultBuildOperationExecutor$CallableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:406) at org.gradle.internal.operations.DefaultBuildOperationExecutor$1.execute(DefaultBuildOperationExecutor.java:165) at org.gradle.internal.operations.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:250) at org.gradle.internal.operations.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:158) at org.gradle.internal.operations.DefaultBuildOperationExecutor.call(DefaultBuildOperationExecutor.java:102) at org.gradle.internal.operations.DelegatingBuildOperationExecutor.call(DelegatingBuildOperationExecutor.java:36) at org.gradle.workers.internal.AbstractWorker.executeWrappedInBuildOperation(AbstractWorker.java:41) at org.gradle.workers.internal.NoIsolationWorkerFactory$1.execute(NoIsolationWorkerFactory.java:55) at org.gradle.workers.internal.DefaultWorkerExecutor$1.call(DefaultWorkerExecutor.java:105) at org.gradle.workers.internal.DefaultWorkerExecutor$1.call(DefaultWorkerExecutor.java:99) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at org.gradle.internal.work.DefaultConditionalExecutionQueue$ExecutionRunner.runExecution(DefaultConditionalExecutionQueue.java:215) at org.gradle.internal.work.DefaultConditionalExecutionQueue$ExecutionRunner.runBatch(DefaultConditionalExecutionQueue.java:164) at org.gradle.internal.work.DefaultConditionalExecutionQueue$ExecutionRunner.run(DefaultConditionalExecutionQueue.java:131) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:63) at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:46) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:55) at java.lang.Thread.run(Thread.java:748) Caused by: com.android.tools.r8.CompilationFailedException: Compilation failed to complete at com.android.tools.r8.utils.t.a(:55) at com.android.tools.r8.D8.run(:11) at com.android.builder.dexing.D8DexArchiveMerger.mergeDexArchives(D8DexArchiveMerger.java:116) ... 30 more Caused by: com.android.tools.r8.utils.AbortException: Error: Program type already present: a.a.a at com.android.tools.r8.utils.Reporter.a(:21) at com.android.tools.r8.utils.Reporter.a(:7) at com.android.tools.r8.utils.t.a(:36) ... 32 more

FAILURE: Build failed with an exception.

  • What went wrong: Execution failed for task ':app:mergeDexProdRelease'.

    A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade com.android.builder.dexing.DexArchiveMergerException: Error while merging dex archives: Learn how to resolve the issue at https://developer.android.com/studio/build/dependencies#duplicate_classes. Program type already present: a.a.a

I am not sure what this file mean lot alot of search but failed to create build.

I am using the following dependencies:

implementation fileTree(include: ['*.jar'], dir: 'libs')

implementation 'androidx.legacy:legacy-support-v4:1.0.0'

implementation 'androidx.recyclerview:recyclerview:1.0.0'

implementation 'androidx.cardview:cardview:1.0.0'

implementation 'androidx.constraintlayout:constraintlayout:1.1.3'

implementation 'com.google.android.material:material:1.0.0'

implementation 'org.jetbrains.kotlin:kotlin-stdlibjdk7:1.3.50'

implementation 'androidx.lifecycle:lifecycle-runtime:2.2.0-alpha03'

implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0-alpha03'

implementation 'androidx.lifecycle:lifecycle-reactivestreams:2.2.0-alpha03'
implementation 'com.squareup.retrofit2:retrofit:2.5.0'

implementation 'com.squareup.retrofit2:converter-gson:2.3.0'

implementation 'com.squareup.retrofit2:adapter-rxjava2:2.5.0'

implementation 'com.squareup.okhttp3:logging-interceptor:3.11.0'

implementation 'io.reactivex.rxjava2:rxkotlin:2.3.0'

implementation 'com.facebook.stetho:stetho-okhttp3:1.5.0'

implementation 'com.squareup.picasso:picasso:2.71828'

implementation 'io.reactivex.rxjava2:rxandroid:2.1.0'

implementation 'com.daimajia.swipelayout:library:1.2.0@aar'

implementation 'com.chauthai.swipereveallayout:swipe-reveal-layout:1.4.1'

implementation 'androidx.multidex:multidex:2.0.1'

implementation 'com.google.android.gms:play-services-vision:18.0.0'

implementation 'io.card:android-sdk:5.5.1'

implementation 'com.localytics.android:library:5.6.1'

implementation 'net.zetetic:android-database-sqlcipher:4.0.1@aar'

implementation 'androidx.legacy:legacy-support-v4:1.0.0'


implementation 'com.adobe.mobile:adobeMobileLibrary:4.13.7'

implementation 'com.newrelic.agent.android:android-agent:5.22.1'

implementation 'androidx.camera:camera-core:1.0.0-alpha03'

implementation 'androidx.camera:camera-camera2:1.0.0-alpha03'

implementation 'androidx.appcompat:appcompat:1.1.0-rc01'

implementation 'com.google.android.gms:play-services-ads-identifier:16.0.0'

implementation(project(':SA')) {      transitive = true   }

implementation 'com.android.installreferrer:installreferrer:1.0'

implementation 'androidx.room:room-runtime:2.1.0'

implementation 'de.hdodenhof:circleimageview:3.0.0'

annotationProcessor 'androidx.room:room-compiler:2.1.0'

implementation 'com.jaeger.statusbarutil:library:1.4.0'

implementation 'com.sasank.roundedhorizontalprogress:roundedhorizontalprogress:1.0.1'

testImplementation 'junit:junit:4.12'

testImplementation 'org.mockito:mockito-core:2.19.0'

androidTestImplementation 'androidx.test:runner:1.2.0'

androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'

implementation 'com.google.firebase:firebase-core:16.0.7'

implementation 'com.google.firebase:firebase-messaging:19.0.0'

implementation 'com.google.firebase:firebase-ml-vision:21.0.0'

implementation 'me.saket:better-link-movement-method:2.2.0'

implementation 'com.tbuonomo.andrui:viewpagerdotsindicator:4.0'

implementation 'com.google.ar.sceneform.ux:sceneform-ux:1.11.0'`

So I have updated this: implementation(project(':SA')) {transitive = true }

to implementation files('libs/SA.aar')

Now I am getting this error:

java.lang.RuntimeException: Duplicate class a.a.a found in modules classes.jar (SA.aar) and classes.jar (com.google.ar:core:1.12.0)
  Duplicate class a.a.b found in modules classes.jar (SA.aar) and classes.jar (com.google.ar:core:1.12.0)
  Duplicate class com.google.a.a.a found in modules classes.jar (SA.aar) and classes.jar (com.google.ar:core:1.12.0)
  Duplicate class com.google.a.a.b found in modules classes.jar (SA.aar) and classes.jar (com.google.ar:core:1.12.0)

How should I resolve this?

3 Answers

So you have an obfuscated build here, try disabling this obfuscation first and see if the issue persists.

If it persists it is likely showing you the actual dangling class, which - most of the time - points you to one or more libraries that depend on a conflicting 3rd party dependency, in which case you'd simply exclude that dependency from being included transitively into your build.

If it does not persist in a non-obfuscated build, check your symbols file to get the name of the class / program type a.a.a was obfuscated to. This file usually resides somewhere underneath app/build/outputs/**/mapping.txt.

It might also totally be a temporary issue, in this case make a clean build and try again.

Seeing your build.gradle file it looks you have added legacy library and your SA module twice

implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation(project(':SA')) {transitive = true}

The culprit is the second one.

Maybe that can be the your issue as the error says about duplicates.

Trying removing the same or maybe you dont need that legacy library itself I think.

Because sometimes it gets added in my build.gradle automatically and I have to remove that manually.

I faced problem like this and

cd android && ./gradlew clean 

helped me

Related