Running Error:Execution failed for task ':app:transformResourcesWithMergeJavaResForDebug' - android

Running Error Execution failed for task ':app:transformResourcesWithMergeJavaResForDebug'
So I'm continuously receiving a gradle build error upon trying to run my project. I have searched for other solutions and some say that adding:
packagingOptions {
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE' // will not include LICENSE file
// as noted by #Vishnuvathsan you may also need to include
// variations on the file name. It depends on your dependencies.
// Some other common variations on notice and license file names
exclude 'META-INF/notice'
exclude 'META-INF/notice.txt'
exclude 'META-INF/license'
exclude 'META-INF/license.txt'
}
But it doesn't work for me.The Error as below:
Error:Execution failed for task ':app:transformResourcesWithMergeJavaResForDebug'.
com.android.build.api.transform.TransformException: com.android.builder.packaging.DuplicateFileException: Duplicate files copied in APK META-INF/rxjava.properties
**File1: E:\Workspace_Android\TravelStory\app\build\intermediates\exploded-aar\cn.bmob.android\bmob-sdk\3.5.0\jars\classes.jar
File2: C:\Users\Prometheus\.gradle\caches\modules-2\files-2.1\io.reactivex\rxjava\1.2.1\4e4cfa4adc74521d5966799fa5ab70b733552f68\rxjava-1.2.1.jar**
I try to delete the File2 but after compile/gradle the file created again.
studio version is 2.2.3
gradle version is 2.2.3
My gradle file content as below:
apply plugin: 'com.android.application'
apply plugin: 'android-apt'
android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
defaultConfig {
applicationId "com.example.travelstory.travelstory"
minSdkVersion 15
targetSdkVersion 25
versionCode 1
versionName "1.0"
multiDexEnabled true;
}
packagingOptions {
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE' // will not include LICENSE file
// as noted by #Vishnuvathsan you may also need to include
// variations on the file name. It depends on your dependencies.
// Some other common variations on notice and license file names
exclude 'META-INF/notice'
exclude 'META-INF/notice.txt'
exclude 'META-INF/license'
exclude 'META-INF/license.txt'
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
configurations.all {
resolutionStrategy.force 'com.google.code.findbugs:jsr305:3.0.1'
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:25.1.0'
compile 'com.android.support:design:25.0.1'
compile 'com.android.support:multidex:1.0.1'
//屏幕自动适配
compile 'com.zhy:autolayout:1.4.5'
//注解框架
compile 'com.jakewharton:butterknife:8.4.0'
apt 'com.jakewharton:butterknife-compiler:8.4.0'
//6.0权限rx
compile 'com.tbruyelle.rxpermissions:rxpermissions:0.9.1#aar'
//RxJava RxLifecycle生命周期管理
compile 'com.trello:rxlifecycle:1.0'
compile 'com.trello:rxlifecycle-components:1.0'
//3.5.0:请务必查看下面注释[1]
compile ('cn.bmob.android:bmob-sdk:3.5.0')
// {
// exclude group: 'io.reactivex:rxjava:1.1.6'
// }
//如果你想应用能够兼容Android6.0,请添加此依赖(org.apache.http.legacy.jar)
compile 'cn.bmob.android:http-legacy:1.0'
//bmob-push:Bmob的推送包
compile 'cn.bmob.android:bmob-push:0.8'
//多fragment多模块Activity
compile 'me.yokeyword:fragmentation:0.9.3'
// 如果想使用SwipeBack 滑动边缘退出Fragment/Activity功能,请再添加下面的库
compile 'me.yokeyword:fragmentation-swipeback:0.7.9'
}

Your not excluding the file the error is warning about.
com.android.build.api.transform.TransformException: com.android.builder.packaging.DuplicateFileException: Duplicate files copied in APK META-INF/rxjava.properties
Here the complaint is META-INF/rxjava.properties so just update your packageOptions block to exclude this file explicitly.
packagingOptions {
exclude 'META-INF/rxjava.properties'
// ... and any other excludes go here
}

Update your gradle with this code:
packagingOptions {
exclude 'META-INF/DEPENDENCIES.txt'
exclude 'META-INF/NOTICE'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE.txt'
}
This happens when there is a duplication of libraries

Related

How to fix this error when I run project firebase phone authentication

I use this dependencies
compile 'com.google.firebase:firebase-auth:11.4.2'
Error:
Error:Execution failed for task ':app:transformResourcesWithMergeJavaResForDebug'.
com.android.build.api.transform.TransformException: com.android.builder.packaging.DuplicateFileException: Duplicate files copied in APK META-INF/maven/com.fasterxml.jackson.core/jackson-core/pom.properties
File1: C:\Users\Usman.gradle\caches\modules-2\files-2.1\com.fasterxml.jackson.core\jackson-core\2.2.2\d20be6a5ddd6f8cfd36ebf6dea329873a1c41f1b\jackson-core-2.2.2.jar
File2: D:\eRozgaar\app\build\intermediates\exploded-aar\com.google.android.gms\play-services-basement\11.4.2\jars\classes.jar
my build.gradil is :
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.3"
defaultConfig {
applicationId "com.example.usman.erozgaar"
minSdkVersion 21
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'),
'proguard-rules.pro'
}
}
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'
}
}
dependencies {
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.4.0'
compile 'com.firebase:firebase-client-android:2.5.2+'
compile 'com.google.firebase:firebase-core:11.4.2'
compile 'com.android.volley:volley:1.0.0'
// compile 'com.google.firebase:firebase-core:10.0.1'
// compile 'com.firebase:firebase-ui-storage:0.6.0'
compile 'com.google.firebase:firebase-auth:11.4.2'
compile 'com.github.bumptech.glide:glide:3.7.0'
compile 'com.google.firebase:firebase-database:11.0.1'
compile 'com.google.firebase:firebase-storage:11.0.1'
}
You can try to add the following line to the bottom in your app's build.gradle, inside the android {} and below your dependencies {}.
packagingOptions {
exclude 'META-INF/maven'
}
This will remove unnecessary files during your build, which should prevent your duplicate file exception which is caused by merging your dependencies.
See: com.android.builder.packaging.DuplicateFileException: Duplicate files copied in APK META-INF/maven/com.fasterxml.jackson.core/jackson-databind/pom.xml
Solution of my problem was
packagingOptions
{
exclude 'META-INF/maven/com.fasterxml.jackson.core/jackson-
core/pom.properties'
exclude 'META-INF/services/com.fasterxml.jackson.core.JsonFactory'
exclude 'META-INF/maven/com.fasterxml.jackson.core/jackson-core/pom.xml'
}
duplicate file link copy from error message and past in
packagingOptions
{
exclude 'past here copied file link'
}

Android gradle build gives DuplicateFileException

Hi after adding apache poi gradle build , Im getting this expection. Could you please explain me what it is how to resolve it.
I have tried excluding package options in many ways, didn't worked
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:25.1.0'
testCompile 'junit:junit:4.12'
compile 'com.android.support:design:25.1.0'
compile 'com.android.support:cardview-v7:25.1.0'
compile 'org.greenrobot:greendao:3.2.0'
compile group: 'org.apache.poi', name: 'poi-ooxml', version: '3.9'
}
Error:Execution failed for task ':app:transformResourcesWithMergeJavaResForDebug'.
com.android.build.api.transform.TransformException: com.android.builder.packaging.DuplicateFileException: Duplicate files copied in APK META-INF/LICENSE
File1: /home/surendra/.gradle/caches/modules-2/files-2.1/org.apache.poi/poi-ooxml-schemas/3.9/4c514498f0e82cccfdd3208b9caff2f45158db4a/poi-ooxml-schemas-3.9.jar
File2: /home/surendra/.gradle/caches/modules-2/files-2.1/org.apache.poi/poi-ooxml/3.9/bbe83c739d22eecfacd06d7e0b99ba13277040ed/poi-ooxml-3.9.jar
File3: /home/surendra/.gradle/caches/modules-2/files-2.1/org.apache.poi/poi/3.9/5d5e41354e88322e4bc590b31f3d2d1d52b3e6ac/poi-3.9.jar
try this exclude the duplicated file by using below code
packagingOptions {
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
pickFirst 'META-INF/license.txt'
}
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"
}
For better reference visit this answer.
exclude the duplicated file by adding this to you gradle file
android {
...
packagingOptions {
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
}
}

Android Studio: Duplicate files copied in APK project.properties

After adding the Google Translate API compile 'com.google.cloud:google-cloud-translate:0.18.0-beta' to my project, I have been getting a strange error
Error:Execution failed for task ':ParseStarterProject:transformResourcesWithMergeJavaResForDebug'.
com.android.build.api.transform.TransformException: com.android.builder.packaging.DuplicateFileException: Duplicate files copied in APK project.properties
File1: .gradle/caches/modules-2/files-2.1/com.google.cloud/google-cloud-translate/0.18.0-beta/9cac04f2bb48f76f352bf65d782506e4aa18406c/google-cloud-translate-0.18.0-beta.jar
File2: /.gradle/caches/modules-2/files-2.1/com.google.cloud/google-cloud-core/1.0.2/ff451b4b785369093bd91d277c22576fc9c1da3a/google-cloud-core-1.0.2.jar
There are other SO posts which mention "Duplicate files copied in APK META_INF", or "Duplicate files copied in APK LICENSE.txt", etc
However, I have not seen anyone else encounter the error "duplicate files copied in APK project.properties"
Adding these to my gradle does not work
packagingOptions {
exclude 'META-INF/LICENSE'
exclude 'META-INF/io.netty.versions.properties'
exclude 'META-INF/INDEX.LIST'
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
}
Is there something else I can add to my gradle to fix this error? Or is there another way to fix this error by removing "FILE2" as shown in the error logs?
GRADLE
apply plugin: 'com.android.application'
android {
useLibrary 'org.apache.http.legacy'
packagingOptions {
// exclude 'META-INF/LICENSE'
//exclude 'META-INF/io.netty.versions.properties'
//exclude 'META-INF/INDEX.LIST'
}
compileSdkVersion rootProject.ext.compileSdkVersion
buildToolsVersion rootProject.ext.buildToolsVersion
defaultConfig {
multiDexEnabled true
applicationId "com.package.name"
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 41
versionName "2.1"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
lintOptions {
disable 'MissingTranslation'
disable 'ExtraTranslation'
}
dexOptions {
javaMaxHeapSize "4g"
}
repositories {
mavenCentral()
}
dependencies {
compile 'com.google.firebase:firebase-core:10.2.0'
compile 'com.google.firebase:firebase-messaging:10.2.0'
//noinspection GradleCompatible
compile 'com.google.cloud:google-cloud-translate:0.18.0-beta'
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support:design:25.3.1'
compile 'com.parse.bolts:bolts-tasks:1.3.0'
compile 'com.parse:parse-android:1.13.0'
compile 'com.android.support:multidex:1.0.1'
//noinspection GradleDynamicVersion
compile 'com.facebook.android:facebook-android-sdk:[4,5)'
//noinspection GradleCompatible
compile 'com.google.android.gms:play-services-ads:10.2.0'
// compile 'com.onesignal:OneSignal:3.4.3#aar'
}
}
apply plugin: 'com.google.gms.google-services'
dependencies {
compile 'com.android.support.constraint:constraint-layout:1.0.1'
}
in my case,
packagingOptions {
exclude 'META-INF/LICENSE'
exclude 'META-INF/io.netty.versions.properties'
exclude 'META-INF/INDEX.LIST'
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
exclude 'project.properties' <------------------------here
}
Remove the google cloud core dependancy
While adding translate dependancy do this
compile ('com.google.cloud:google-cloud-translate:0.5.0') {
exclude group: 'io.grpc', module: 'grpc-all'
exclude group: 'com.google.protobuf', module: 'protobuf-java'
exclude group: 'com.google.api-client', module: 'google-api-client-
appengine'
}

Duplicate files copied in APK AUTHORS - ombok-ast-0.2.3.jar

I tried data binding and I need change build:gradle like this:
classpath 'com.android.tools.build:gradle:2.2.0'
now I cant run my project
FAILURE: Build failed with an exception.
What went wrong:
Execution failed for task ':app:transformResourcesWithMergeJavaResForDebug'.
com.android.build.api.transform.TransformException: com.android.builder.packaging.DuplicateFileException: Duplicate files copied in APK AUTHORS
File1: C:\Program Files\Android\Android Studio\gradle\m2repository\com\android\tools\external\lombok\lombok-ast\0.2.3\lombok-ast-0.2.3.jar
File2: C:\Program Files\Android\Android Studio\gradle\m2repository\com\android\tools\external\lombok\lombok-ast\0.2.3\lombok-ast-0.2.3.jar
my build.gradle :
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion '25.0.0'
defaultConfig {
applicationId "***"
minSdkVersion 19
targetSdkVersion 25
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
packagingOptions {
exclude 'META-INF/NOTICE' // will not include NOTICE file
exclude 'META-INF/LICENSE' // will not include LICENSE file
// as noted by #Vishnuvathsan you may also need to include
// variations on the file name. It depends on your dependencies.
// Some other common variations on notice and license file names
exclude 'META-INF/notice'
exclude 'META-INF/notice.txt'
exclude 'META-INF/license'
exclude 'META-INF/license.txt'
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
compile project(':**')
compile project(':**')
// compile 'com.android.support:appcompat-v7:24.2.1'
// compile 'com.android.support:design:24.2.1'
// compile 'com.android.support:recyclerview-v7:24.2.1'
// compile 'me.grantland:autofittextview:0.2.+'
compile 'com.android.support:appcompat-v7:25.1.0'
compile 'com.android.support:design:25.1.0'
compile 'com.android.support:cardview-v7:25.1.0'
compile 'com.android.support:recyclerview-v7:25.1.0'
compile 'com.google.code.gson:gson:2.8.0'
compile 'com.android.support:support-annotations:25.1.0'
compile 'com.android.support:support-v4:25.1.0'
compile 'org.jsoup:jsoup:1.7.3'
}
Like the error states you're trying to package the AUTHORS file from different jars; so you should just exclude it from being packaged.
packagingOptions {
exclude 'AUTHORS' // will not include AUTHORS file
}
You should merge your other packagingOptions files like this
packagingOptions {
exclude 'AUTHORS' // will not include AUTHORS file
exclude 'META-INF/NOTICE' // will not include NOTICE file
exclude 'META-INF/LICENSE' // will not include LICENSE file
// as noted by #Vishnuvathsan you may also need to include
// variations on the file name. It depends on your dependencies.
// Some other common variations on notice and license file names
exclude 'META-INF/notice'
exclude 'META-INF/notice.txt'
exclude 'META-INF/license'
exclude 'META-INF/license.txt'
}

Android app not building: Duplicate files copied in APK META-INF/INDEX.LIST

I'm getting the following error when I try to run the Android app.
Error:Execution failed for task ':app:transformResourcesWithMergeJavaResForDebug'.
> com.android.build.api.transform.TransformException: com.android.builder.packaging.DuplicateFileException: Duplicate files copied in APK META-INF/INDEX.LIST
File1: /Users/Antrromet/.gradle/caches/modules-2/files-2.1/org.apache.xmlbeans/xmlbeans/2.6.0/29e80d2dd51f9dcdef8f9ffaee0d4dc1c9bbfc87/xmlbeans-2.6.0.jar
File2: /Users/Antrromet/.gradle/caches/modules-2/files-2.1/edu.ucar/cdm/4.5.5/af1748a3d024069cb7fd3fc2591efe806c914589/cdm-4.5.5.jar
File3: /Users/Antrromet/.gradle/caches/modules-2/files-2.1/edu.ucar/httpservices/4.5.5/ee5f217be599e5e03f7f0e55e03f9e721a154f62/httpservices-4.5.5.jar
File4: /Users/Antrromet/.gradle/caches/modules-2/files-2.1/edu.ucar/netcdf4/4.5.5/675d63ecc857c50dd50858011b670160aa30b62/netcdf4-4.5.5.jar
File5: /Users/Antrromet/.gradle/caches/modules-2/files-2.1/edu.ucar/grib/4.5.5/cfe552910e9a8d57ce71134796abb281a74ead16/grib-4.5.5.jar
File6: /Users/Antrromet/.gradle/caches/modules-2/files-2.1/edu.ucar/udunits/4.5.5/d8c8d65ade13666eedcf764889c69321c247f153/udunits-4.5.5.jar
I know there are similar questions here and here, and I've taken hints from both of them. This is how my gradle file looks like.
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "com.antrromet.androidtikaparser"
minSdkVersion 15
targetSdkVersion 23
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'
exclude 'META-INF/maven/edu.ucar/udunits/pom.xml'
exclude 'META-INF/maven/edu.ucar/udunits/pom.properties'
exclude 'META-INF/maven/edu.ucar/netcdf4/pom.xml'
exclude 'META-INF/maven/edu.ucar/netcdf4/pom.properties'
exclude 'META-INF/maven/edu.ucar/cdm/pom.xml'
exclude 'META-INF/maven/edu.ucar/cdm/pom.properties'
exclude 'META-INF/maven/edu.ucar/grib/pom.xml'
exclude 'META-INF/maven/edu.ucar/grib/pom.properties'
exclude 'META-INF/maven/org.apache.xmlbeans/xmlbeans/pom.xml'
exclude 'META-INF/maven/org.apache.xmlbeans/xmlbeans/pom.properties'
exclude 'META-INF/maven/edu.ucar/httpservices/pom.xml'
exclude 'META-INF/maven/edu.ucar/httpservices/pom.properties'
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.2.1'
compile('org.apache.tika:tika-parsers:1.12') {
exclude group: 'commons-logging', module: 'commons-logging'
exclude group: 'org.json', module: 'json'
exclude group: 'org.apache.httpcomponents', module: 'httpclient'
}
}
Any suggestions as to how to solve this? Thanks in advance!
EDIT 1
When I add exclude 'META-INF/INDEX.LIST', the error changes to the following,
Error:Execution failed for task ':app:transformResourcesWithMergeJavaResForDebug'.
> com.android.build.api.transform.TransformException: com.android.builder.packaging.DuplicateFileException: Duplicate files copied in APK META-INF/services/org.apache.sis.storage.DataStoreProvider
File1: /Users/Antrromet/.gradle/caches/modules-2/files-2.1/org.apache.sis.storage/sis-storage/0.5/29d1ea6422b68fbfe1f1702f122019ae376ee2c8/sis-storage-0.5.jar
File2: /Users/Antrromet/.gradle/caches/modules-2/files-2.1/org.apache.sis.storage/sis-netcdf/0.5/2b416e4506caebe7df6dd21b878dae888e0eea39/sis-netcdf-0.5.jar
And after that if you add the following,
exclude 'META-INF/maven/org.apache.sis.storage/sis-netcdf/pom.xml'
exclude 'META-INF/maven/org.apache.sis.storage/sis-netcdf/pom.properties'
exclude 'META-INF/maven/org.apache.sis.storage/sis-storage/pom.xml'
exclude 'META-INF/maven/org.apache.sis.storage/sis-storage/pom.properties'
Its the exact same error as above. It doesn't change.
You need to add the following exclude:
exclude 'META-INF/services/org.apache.sis.storage.DataStoreProvider'

Categories

Resources