Android Studio 0.4 Duplicate Files Copied in APK Meta-Inf/License.Txt

Android Studio 0.4 Duplicate files copied in APK META-INF/LICENSE.txt

Putting the dependecies at the top and the packageOptions at the end worked for me.

apply plugin: 'android'. 

Here is my full build.gradle at the app folder.

dependencies {
compile 'com.android.support:support-v4:+'
compile files('libs/apache-mime4j-0.6.jar')
compile files('libs/httpmime-4.0.jar')
}

android {
compileSdkVersion 19
buildToolsVersion "19.0.1"

defaultConfig {
minSdkVersion 7
targetSdkVersion 10
versionCode 1
versionName "1.0"
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard- rules.txt'
}


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'
}
}

EDIT: Almost all OS licence include the obligation to "include a copy of the licence" into your project. So this means, that you have to include a copy of all OS licences you use into you projects. By "excluding" them in gradle, you violate the licences.

Excluding them from the project might not be the best option.
Thank you R.S. for the info.

Duplicate lib file copied in APK-META-INF/license.txt error in Android Studio

Go to your build.gradle file and add the following line:

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

In my case I had to add like this one:

apply plugin: 'com.android.library'    
android {
compileSdkVersion 21
buildToolsVersion "21.1.2"

defaultConfig {
minSdkVersion 14
targetSdkVersion 21
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
packagingOptions {
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:appcompat-v7:+'
compile 'com.google.android.gms:play-services:6.5.87'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.mcxiaoke.volley:library:1.0.15'
compile 'com.google.code.gson:gson:2.2.4'
compile "org.apache.httpcomponents:httpcore:4.4.1"
compile "org.apache.httpcomponents:httpmime:4.3.6"


}

Note:

  1. Meta-files doesn't affect any programmatic functions of application. Meta files basically contains Textual information like legal-notice, Licences etc of open sources libraries. Excluding it will not affect any thing.

  2. When we use multiple 3rd party open source libraries, sometimes 2 or more projects has same named text files (Example: License.txt or Notice.txt or dependencies.txt). That causes the conflict during build time. In that moment our mighty android studio suggest us to exclude those conflicting meta files.

How do I resolve Duplicate files copied in APK META-INF/*

There is a solution if you have only one license using the name license.txt (read: all license.txt copies are identical):

packagingOptions {
pickFirst 'META-INF/license.txt'
}

Otherwise, Google also released a Gradle plugin to manage dependencies licenses. See here. I didn't try it, but it looks like it's capable of aggregating every dependency, and even generating an activity displaying all of those licenses.

Duplicate files copied in APK META-INF/LICENSE.txt. PackagingOptions doesnt helps

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

Error :: duplicate files during packaging of APK

I think the string comparison is case sensitive. try with exclude 'META-INF/notice.txt'

Duplicate Files copied in APK META-INF when Gradle building

I had to add the following lines to packagingOptions {}

exclude 'META-INF/maven/commons-io/commons-io/pom.xml'
exclude 'META-INF/maven/commons-io/commons-io/pom.properties'

My problem was pretty foolish; when including exclude 'META-INF/maven/commons-io/commons-io/pom.xml' I got an error that looked very similar to the first one, but was in fact different. adding exclude 'META-INF/maven/commons-io/commons-io/pom.properties' finally got everything working. Still not sure why exactly I have to take these steps though.

Duplicate files copied (Android Studio 0.4.0)

According to comment 14 in this bug: https://code.google.com/p/android/issues/detail?id=61573#c14 this is a bug in v0.7.0 of the Android Gradle plugin, and is due to be fixed soon in 0.7.1.

EDIT

Here are the notes from that bug about the addition for 0.7.1:

0.7.1 is out with the fix for this.

The DSL to exclude files is:

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

You can add as many exclude statement as you want. The value is the archive path. No wildcard or glob support yet.

Error :: duplicate files during packaging of APK

I think the string comparison is case sensitive. try with exclude 'META-INF/notice.txt'



Related Topics



Leave a reply



Submit