1

Although I have read similar questions and tried to apply this code :

packagingOptions {
    exclude  'META-INF/LICENSE.txt'
}

in my app build.gradle I still get the same error.

The error message in logcat:

    Error:Execution failed for task ':kalturaClient:transformResourcesWithMergeJavaResForRelease'.
> com.android.build.api.transform.TransformException: com.android.builder.packaging.DuplicateFileException: Duplicate files copied in APK META-INF/LICENSE.txt
    File1: /home/teo/Documents/AndroidStudioWorkspace/Kaltura/DemoApplication/kalturaClient/libs/commons-codec-1.4.jar
    File2: /home/teo/Documents/AndroidStudioWorkspace/Kaltura/DemoApplication/kalturaClient/libs/commons-httpclient-3.1.jar

I have also tried to clean project but with no luck. I'm using Android Studio 1.5.1

My build.gradle file is :

apply plugin: 'com.android.application'

android {
compileSdkVersion 23
buildToolsVersion "23.0.1"

defaultConfig {
    applicationId "com.kaltura.activity"
    minSdkVersion 8
    targetSdkVersion 23
}

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

packagingOptions {
    exclude 'META-INF/LICENSE.txt'
}

}

dependencies {
compile project(':kalturaClient')
compile 'com.android.support:support-v4:23.0.1'
compile files('libs/WidevineDRM-Debug-5.0.0.12188.jar')
compile files('libs/apksigtool.jar')
compile files('libs/commons-codec-1.4.jar')
compile files('libs/commons-httpclient-3.1.jar')
compile files('libs/simple-social-sharing-1.0.0.jar')
compile files('libs/universal-image-loader-1.2.1.jar')
}
RushDroid
  • 1,570
  • 3
  • 21
  • 46
mt0s
  • 5,781
  • 10
  • 42
  • 53

2 Answers2

4

You should add

android {
    // Fixed build error : Duplicate files copied in APK META-INF/LICENSE.txt
    packagingOptions {
        exclude 'META-INF/DEPENDENCIES'
        exclude 'META-INF/NOTICE'
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/NOTICE.txt'
        exclude 'META-INF/LICENSE.txt'
    }
}

More details You may visit Android Studio 0.4 Duplicate files copied in APK META-INF/LICENSE.txt

Community
  • 1
  • 1
IntelliJ Amiya
  • 74,896
  • 15
  • 165
  • 198
1

try with this.

packagingOptions {
        pickFirst 'META-INF/NOTICE.txt'
        pickFirst 'META-INF/DEPENDENCIES.txt'
        pickFirst 'META-INF/LICENSE.txt'
    }
    packagingOptions {
        exclude 'META-INF/DEPENDENCIES'
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/NOTICE'
    }

Hope it will help you.

RushDroid
  • 1,570
  • 3
  • 21
  • 46