0

I have found this error when running my app,and I tried some solutions for this problem.But it is not solved my problem.

I have added these lines to my build.gradle file

 packagingOptions {
    exclude  'META-INF/NOTICE'
    exclude 'META-INF/DEPENDENCIES'
    exclude 'META-INF/LICENCE'
}

But still there is same errors. Error log

Error:duplicate files during packaging of APK I:\CameraPhotoVideoUpload\app\build\outputs\apk\app-debug-unaligned.apk
Path in archive: META-INF/LICENSE
Origin 1: I:\CameraPhotoVideoUpload\app\libs\httpmime-4.3.6.jar
Origin 2: I:\CameraPhotoVideoUpload\app\libs\httpclient-4.3.6.jar
You can ignore those files in your build.gradle:
android {
  packagingOptions {
    exclude 'META-INF/LICENSE'
  }
}
Error:Execution failed for task ':app:packageDebug'.
> Duplicate files copied in APK META-INF/LICENSE
File 1: I:\CameraPhotoVideoUpload\app\libs\httpmime-4.3.6.jar
File 2: I:\CameraPhotoVideoUpload\app\libs\httpclient-4.3.6.jar
Information:BUILD FAILED

I could not understand the problem .Can anyone help??

Gradle file

apply plugin: 'com.android.application'

android {
packagingOptions {
    exclude 'META-INF/NOTICE'
    exclude 'META-INF/DEPENDENCIES'
    exclude 'META-INF/LICENCE'
}

compileSdkVersion 21
buildToolsVersion "23.0.0 rc2"

defaultConfig {
    applicationId "info.androidhive.camerafileupload"
    minSdkVersion 11
    targetSdkVersion 21
}

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

dependencies {
    compile 'com.android.support:appcompat-v7:21.0.3'
    compile 'com.android.support:support-v4:21.0.3'
    compile files('libs/httpclient-4.3.6.jar')
    compile files('libs/httpcore-4.3.3.jar')
    compile files('libs/httpmime-4.3.6.jar')
}
}
Jack
  • 1,825
  • 3
  • 26
  • 43

2 Answers2

1

Replace your gradle with this

apply plugin: 'com.android.application'

android {
    compileSdkVersion 22
    buildToolsVersion "21.1.2"

    defaultConfig {
        applicationId "your_package_name"
        minSdkVersion 14
        targetSdkVersion 22
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
   packagingOptions {
      exclude 'META-INF/NOTICE'
      exclude 'META-INF/DEPENDENCIES'
      exclude 'META-INF/LICENCE'
      }
     }

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:22.0.0'
    <!--Jar's Goes Here-->
}

Still getting the error means replace packagingOptions

 packagingOptions {
        exclude 'META-INF/DEPENDENCIES'
        exclude 'META-INF/NOTICE'
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/LICENSE.txt'
        exclude 'META-INF/NOTICE.txt'
    }
Anoop M Maddasseri
  • 10,213
  • 3
  • 52
  • 73
  • From the link http://comments.gmane.org/gmane.comp.handhelds.android.adt.devel/2989 .The change in 0.7.1+ is that it is now possible to tweak the packaging to exclude files that are unneeded. The build system itself cannot know a priority which files you don't care about; in general duplicate files are an error that needs to be addressed by the developer. – Anoop M Maddasseri Jul 01 '15 at 07:05
  • Checkout http://stackoverflow.com/questions/25483410/duplicate-files-during-packaging-of-apk-app-debug-unaligned-apk – Anoop M Maddasseri Jul 01 '15 at 07:09
0

String comparision is case sensitive so try

  packagingOptions {
    exclude  'META-INF/NOTICE'
    exclude 'META-INF/DEPENDENCIES'
    exclude 'META-INF/licence' //write licence in lowercase
}
Adi Tiwari
  • 761
  • 1
  • 5
  • 17
  • if the same error log is obtained after change, then it is sure that there is some problem with names, try LICENCE.txt or licence.txt – Adi Tiwari Jul 01 '15 at 05:55