Anand Jain Anand Jain - 7 months ago 55
Android Question

Error:duplicate files during packaging of APK in android studio

when i try to run my app i faced unknown of error like this:-

Error:duplicate files during packaging of APK D:\andriod App\JsonArray\app\build\outputs\apk\app-debug-unaligned.apk
. and one of another problem come in like this:-

Error:Execution failed for task ':app:packageDebug'.

Duplicate files copied in APK META-INF/LICENSE.txt
File 1: D:\andriod App\JsonArray\app\libs\commons-logging-1.2.jar
File 2: D:\andriod App\JsonArray\app\libs\commons-codec-1.9.jar

apply plugin: ''android {
compileSdkVersion 23
buildToolsVersion "22.0.1"
defaultConfig {
applicationId ""
minSdkVersion 14
targetSdkVersion 23
versionCode 1
versionName "1.0"
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), ''
}}dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile ''}


You should add below code to your gradle file :

android {
     packagingOptions { 
         exclude 'META-INF/LICENSE.txt' 
         exclude 'META-INF/NOTICE.txt' 

Edited :

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile ''
compile 'commons-logging:commons-logging:1.2'
compile 'commons-codec:commons-codec:1.9'

Remove jar(commons-logging and commons-codec ) from libs folder and add this gradle dependency.