My code builds fine, but when I try to run it in debug, I get the following 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/BCKEY.DSA
File1: D:\Android\AndroidStudio\gradle\m2repository\org\bouncycastle\bcpkix-jdk15on\1.48\bcpkix-jdk15on-1.48.jar
File2: C:\Users\beili\.gradle\caches\modules-2\files-2.1\org.bouncycastle\bcprov-jdk15on\1.48\960dea7c9181ba0b17e8bab0c06a43f0a5f04e65\bcprov-jdk15on-1.48.jar
How can I resolve this?
Add this to your build.gradle inside the android section like
android{
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/BCKEY.DSA'
exclude 'AUTHORS'
}
}
Related
I want add com.google.firebase:firebase-admin:7.1.1 to my project
After sync, I get below error:
* What went wrong:
Execution failed for task ':app:transformResourcesWithMergeJavaResForDebug'.
> More than one file was found with OS independent path 'google/protobuf/type.proto'
I use this tutorial: https://firebase.google.com/docs/firestore/quickstart
Also, I added this section:
packagingOptions {
exclude 'project.properties'
exclude 'META-INF/INDEX.LIST'
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/native-image/io.netty/codec-http/native-image.properties'
exclude 'META-INF/io.netty.versions.properties'
exclude 'META-INF/native-image/io.netty/common/native-image.properties'
exclude 'META-INF/native-image/io.netty/transport/native-image.properties'
exclude 'META-INF/native-image/io.netty/transport/reflection-config.json'
exclude 'META-INF/native-image/io.netty/buffer/native-image.properties'
exclude 'META-INF/native-image/io.netty/handler/native-image.properties'
}
try to add the following code may help:
exclude("google/protobuf/type.proto")
and you can refer this link.
After installing a plugin, I'm getting the following error:
Execution failed for task ':transformResourcesWithMergeJavaResForDebug'.
com.android.build.api.transform.TransformException: com.android.builder.packaging.DuplicateFileException: Duplicate files copied in APK META-INF/DEPENDENCIES
File1: C:\Users\Vinicius\Desktop\webapps\paypadapp\platforms\android\libs\httpcore-4.3.2.jar
File2: C:\Users\Vinicius\Desktop\webapps\paypadapp\platforms\android\libs\httpclient-4.3.3.jar
File3: C:\Users\Vinicius\Desktop\webapps\paypadapp\platforms\android\libs\httpmime-4.3.3.jar
When doing a search, I found the following solution
Add this in android manifest:
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'
}
But where do I add that in ionic / cordova?
I created an ionic project from scratch and installed the plugin, the same error occurs
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:
C:\Users\Jithin-PC.gradle\caches\modules-2\files-2.1\com.fasterxml.jackson.core\jackson-core\2.2.2\d20be6a5ddd6f8cfd36ebf6dea329873a1c41f1b\jackson-core-2.2.2.jar
File2:
C:\Users\Jithin-PC.gradle\caches\modules-2\files-2.1\com.fasterxml.jackson.core\jackson-databind\2.2.2\3c8f6018eaa72d43b261181e801e6f8676c16ef6\jackson-databind-2.2.2.jar
File3:
C:\Users\Jithin-PC.gradle\caches\modules-2\files-2.1\com.fasterxml.jackson.core\jackson-annotations\2.2.2\285cb9c666f0f0f3dd8a1be04e1f457eb7b15113\jackson-annotations-2.2.2.jar
Before updating of Android studio to 2.2 it works well. pls help me..
I also faced the same issue a couple of days ago.
This is not a proper solution but more of a hack.
android {
packagingOptions {
// exclude 'META-INF/LICENSE.txt'
// exclude 'META-INF/LICENSE'
// exclude 'META-INF/license.txt'
pickFirst 'META-INF/LICENSE'
}
}
Try it.
I have literally created a brand new Android Project on the latest Android Studio. The first thing I did was to add the `Realm' library to the project by adding the following to the gradle file:
compile 'io.realm:realm-android:0.80.3'
If I try to compile, I get the following error:
Note: C:\....\MainActivity.java uses or overrides a deprecated API.
Origin 2:
C:\Users\Usmaan.gradle\caches\modules-2\files-2.1\io.realm\realm-android\0.80.3\7979d05ba7b919c53766bf98e31aaf0e9feb0590\realm-android-0.80.3.jar Error:duplicate files during packaging of APK
C:...\app\build\outputs\apk\app-debug-unaligned.apk Path in archive:
META-INF/services/javax.annotation.processing.Processor Origin 1:
C:\Users\Usmaan.gradle\caches\modules-2\files-2.1\com.jakewharton\butterknife\6.1.0\63735f48b82bcd24cdd33821342428252eb1ca5a\butterknife-6.1.0.jar
You can ignore those files in your build.gradle: android {
packagingOptions {
exclude 'META-INF/services/javax.annotation.processing.Processor' } Error:Execution failed for task ':app:packageDebug'.
Duplicate files copied in APK META-INF/services/javax.annotation.processing.Processor File 1:
C:\Users\Usmaan.gradle\caches\modules-2\files-2.1\com.jakewharton\butterknife\6.1.0\63735f48b82bcd24cdd33821342428252eb1ca5a\butterknife-6.1.0.jar
File 2:
C:\Users\Usmaan.gradle\caches\modules-2\files-2.1\io.realm\realm-android\0.80.3\7979d05ba7b919c53766bf98e31aaf0e9feb0590\realm-android-0.80.3.jar }
Any ideas?
It looks like you are also using Butterknife? Have you tried adding the below to your build.gradle:
android {
...
packagingOptions {
exclude 'META-INF/services/javax.annotation.processing.Processor'
}
}
Adding this to the android plugin in build.gradle tends to fix these sorts of problems:
packagingOptions {
// Exclude file to avoid
// Error: Duplicate files during packaging of APK
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/license.txt'
exclude 'META-INF/NOTICE'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/notice.txt'
exclude 'META-INF/ASL2.0'
exclude 'META-INF/services/javax.annotation.processing.Processor'
exclude 'META-INF/*.kotlin_module'
}
}
Adding these on build.gradle as Specified in ButterKnife I/O page.
android{
....
packagingOptions {
exclude 'META-INF/services/javax.annotation.processing.Processor'
}
}
lintOptions {
disable 'InvalidPackage'
}
I'm getting a duplicate files error when attempting to build with Gradle.
Error:Execution failed for task ':pauwowandroid:packageDebug'.
> Duplicate files copied in APK LICENSE
File 1: /Users/jasonrobinson/.gradle/caches/modules-2/files-2.1/org.sonatype.sisu.inject/cglib/2.2.1-v20090111/7ce5e983fd0e6c78346f4c9cbfa39d83049dda2/cglib-2.2.1-v20090111.jar
File 2: /Users/jasonrobinson/.gradle/caches/modules-2/files-2.1/org.sonatype.sisu.inject/cglib/2.2.1-v20090111/7ce5e983fd0e6c78346f4c9cbfa39d83049dda2/cglib-2.2.1-v20090111.jar
This is different from other similar errors in that it's complaining the duplicate is in the same file. These are my exclusions:
packagingOptions {
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/LICENSE'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/NOTICE'
exclude 'META-INF/DEPENDENCIES'
}
I still get this error. It's with one particular dependency: Mockito. If I remove that dependency, the error goes away.
Try to add the following exclude:
exclude 'LICENSE.txt'
This should fix it.