skip to Main Content

Android Studio updated to the newest Arctic Fox version, after opening a project it prompted me to update the Gradle plug-in, which I did.

Now everytime I try to run an app (with the updated plug-in) the build fails with the next output: Zip file '/home/user/path-to-my-project/app/build/outputs/apk/debug/app-debug.apk' already contains entry 'AndroidManifest.xml', cannot overwrite

Old apps that are not updated to newest plug-in release does not have this problem.

I already tried with this solution but it didn’t help.

My build.gradle file looks like this:

plugins {
    id 'com.android.application'
    id 'kotlin-android'
}

android {
    compileSdk 30

    defaultConfig {
        applicationId "com.user.oauthpractice"
        minSdk 27
        targetSdk 30
        versionCode 1
        versionName "1.0"

        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
    kotlinOptions {
        jvmTarget = '1.8'
    }
}

dependencies {

    implementation 'androidx.core:core-ktx:1.6.0'
    implementation 'androidx.appcompat:appcompat:1.3.1'
    implementation 'com.google.android.material:material:1.4.0'
    implementation 'androidx.constraintlayout:constraintlayout:2.1.0'
    testImplementation 'junit:junit:4.13.2'
    androidTestImplementation 'androidx.test.ext:junit:1.1.3'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'

    implementation 'com.foursquare:foursquare-android-oauth:1.0.3'
}

3

Answers


  1. After upgrading Android Gradle Plugin from version 3.4.2 to 7.0.0 (and Gradle from 6 to 7) I also stared having the same error. In my case it turned out that AndroidManifest.xml was inside the directory that was pointed to by resources.srcDir. Gradle tried to copy the AndroidManifest.xml from that directory into APK where a compiled version was already bundled.

    Login or Signup to reply.
  2. I tried your build.gradle, after removing implementation 'com.foursquare:foursquare-android-oauth:1.0.3', this problem is gone. No idea what went wrong underneath. You can simply upgrade the version to 1.1.1 to get rid of this problem.

    Login or Signup to reply.
  3. In my case (I upgraded the gradle plugin from 3.6 to 7.1.1) I had a library-project included (the old vending-licensing) and it helped to exclude the manifest like this (inside android{}):

    packagingOptions {
      exclude 'AndroidManifest.xml'
    }
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search