5

When building my Android app with Android-Studio in debug, it works, but when building in release mode, I get the following error at the :app:bundleReleaseClasses step:

Zip file app/build/intermediates/app_classes/release/classes.jar' already contains entry 'META-INF/MANIFEST.MF', cannot overwrite

Building in CLI with ./gradlew assembleDebug (or even ./gradlew bundleReleaseClasses) works.

What could be the reason for this error in Android-Studio, knowing that it works in gradle CLI? I tried excluding this file in packagingOptions {}, but it does not seem to have any effect.

I tried this, this, this, this and a few other related questions, but did not find an answer.

Note that it fails with AGP 7.0.0, 7.0.1, 7.0.2, 7.0.3 and 7.0.4. Not sure if I should try going further back.

JonasVautherin
  • 6,362
  • 6
  • 48
  • 77

2 Answers2

1

I'm facing this issue too and solved it by updating my Gradle wrapper.

Android Studio : Android Studio Bumblebee | 2021.1.1 Patch 3

Current AGP: 7.0.4

Previous Gradle Wrapper: gradle-7.0.2-all.zip (this version causes the issue)

* What went wrong:
Execution failed for task ':app:mergeProdIdnReleaseClasses'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.MergeClassesTask$MergeClassesWorkAction
   > Zip file '/Users/mesin-koding/Development/my/project/app/build/intermediates/module_and_runtime_deps_classes/ProdIdnRelease/base.jar' already contains entry 'com/my/apps/lib/MyLib$Companion$UserProfileConstant.class', cannot overwrite

And in my case, it was solved by updating my Gradle wrapper into gradle-7.2-all.zip

distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-all.zip

heri.sulis
  • 71
  • 3
0

Just Update your Gradle plugin version version

I had the same error in Android Studio Chipmunk| 2021.2.1 and Gradle version 7.1.2 and after updating Gradle plugin version to 7.2.0 this problem is resolved.