Ege Şekercioğlu
Ege Şekercioğlu

Reputation: 21

Error:duplicate files during packaging of APK

I clean and rebuild my project with success but when i run it, it gives me an error. I tried many solution but i couldn't solve with them.

This is my error :

Error:duplicate files during packaging of APK /Users/ege/AndroidStudioProjects/projectandroid/projectAndroid/build/outputs/apk/projectAndroid-debug-unaligned.apk
Path in archive: AndroidManifest.xml
Origin 1: /Users/ege/AndroidStudioProjects/projectandroid/projectAndroid/build/intermediates/resources/resources-debug.ap_
Origin 2: /Users/ege/AndroidStudioProjects/projectandroid/projectAndroid/build/intermediates/javaResources/debug/AndroidManifest.xml
You can ignore those files in your build.gradle:
android {
  packagingOptions {
    exclude 'AndroidManifest.xml'
}
  }
Error:Execution failed for task ':projectAndroid:packageDebug'.
Duplicate files copied in APK AndroidManifest.xml
File 1: /Users/ege/AndroidStudioProjects/projectandroid/projectAndroid/build/intermediates/resources/resources-debug.ap_
File 2: /Users/ege/AndroidStudioProjects/projectandroid/projectAndroid/build/intermediates/javaResources/debug/AndroidManifest.xml

This is my build gradle:

apply plugin: 'com.android.application'
android {
compileSdkVersion 19
buildToolsVersion '23.0.0 rc2'

defaultConfig {
    applicationId "com.project.android"
    minSdkVersion 14
    targetSdkVersion 19

    multiDexEnabled true

}
dexOptions {
    preDexLibraries = false
    javaMaxHeapSize "2g"

}



buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
    }

    packagingOptions {
        exclude 'AndroidManifest.xml'
    }
}




}

   dependencies {
compile project(':slidingMenuLibrary')
compile project(':pullToRefreshLibrary')
compile project(':placeActivity')
compile project(':jMC')
compile project(':salesforceSDK')
compile project(':library')
compile files('../libMaster/android-integration-2.3-SNAPSHOT.jar')
compile files('../libMaster/com.radaee.pdfex_view.jar')
compile files('../libMaster/core-2.3-SNAPSHOT.jar')
compile files('../libMaster/ksoap2-android-assembly-3.2.0-jar-with-dependencies.jar')
compile files('../libMaster/libGoogleAnalyticsServices-v3.01.jar')
compile files('../libMaster/urbanairship-lib-3.0.0.jar')
compile 'com.google.api.client:google-api-client-repackaged-com-google-common-base:1.2.3-alpha'
compile 'com.google.code.gson:gson:2.3.1'
compile ('com.android.support:support-v4:22.2.0'){
    exclude group: 'multidex'
}
compile files('../libMaster/commons-lang3-3.1.jar')
compile files('../libMaster/aws-android-sdk-1.4.4-s3.jar')
compile files('../libMaster/aws-android-sdk-1.4.4-core.jar')
compile files('../libMaster/universal-image-loader-1.8.5-with-sources.jar')
}

I also tried this solution, but didn't work :

packagingOptions {
exclude 'META-INF/DEPENDENCIES.txt'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/notice.txt'
exclude 'META-INF/license.txt'
exclude 'META-INF/dependencies.txt'
exclude 'META-INF/LGPL2.1'
}

Upvotes: 1

Views: 4087

Answers (3)

Arun
Arun

Reputation: 1

Excluding android manifest.xml will help building your apk but none of your plugin will work in that apk

Upvotes: 0

Sushant Gosavi
Sushant Gosavi

Reputation: 3845

packagingOptions should be inside android bracket not in buildTypes like

android {
         packagingOptions {
              exclude 'AndroidManifest.xml'
        }
}

Upvotes: 1

handhand
handhand

Reputation: 756

I currently had the same issue "Duplicate files copied in APK AndroidManifest.xml".

Just do what gradle tell you, putting

android {
  packagingOptions {
      exclude 'AndroidManifest.xml'
}

in build.gradle solved my problem.

Upvotes: 4

Related Questions