Duplicate Files Copied (Android Studio 0.4.0)

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.

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.

Gradle and Android Studio Duplicate File Copied from same jar

As a work around I did the following, which gets my tests to build

Manually add:

  • cglib-nodeps-2.2.2.jar
  • dexmaker-1.0.jar
  • dexmaker-dx-1.0.jar
  • easymock-3.2.jar
  • junit-3.8.2.jar

to test_libs dir,

and add the following to build.gradle:

dependencies {
...
instrumentTestCompile fileTree(dir: 'test_libs', include: '*.jar')
...
}

Everything compiles fine and the tests run:

I also had to do the following: dexmaker-issue2 to fix the no dex cache issue.

Error :: duplicate files during packaging of APK

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

Error:duplicate files during packaging of APK Android Studio Error

Well you are missing the flow of build gradle.
As you are trying to use 2 android {..} snippet it is not detecting the 2nd one. As a result your exclusion of duplicate meta files are not working.

Possible solution:

Just change the order of your build gradle like below:

    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"

}

If it still didn't work then check out the following:

Is it your library build gradle?
I excluded my duplicate meta files from my main projects build gradle. So make sure to exclude the meta files from build gradle of app module rather than library module.

Duplication of files during application build (post gradle update)

It looks like the META-INF/ASL2.0 file is being duplicated. Try adding this to your packagingOptions:

exclude 'META-INF/ASL2.0'`


Related Topics



Leave a reply



Submit