Error:Execution failed for task - android

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.

Related

App fails to build with an error: 2 files found with path 'kotlin/internal/internal.kotlin_builtins'

I tried building my app but it wouldn't build and show this error.
Execution failed for task ':app:mergeDebugJavaResource'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.MergeJavaResWorkAction
> 2 files found with path 'kotlin/internal/internal.kotlin_builtins' from inputs:
- C:\Users\user\.gradle\caches\transforms-3\1203ed0043761220f2e7b9faa528e635\transformed\jetified-kotlin-compiler-embeddable-1.5.31.jar
- C:\Users\user\.gradle\caches\transforms-3\a14ecf8d638c881bd231708fc869e941\transformed\jetified-kotlin-stdlib-1.6.0.jar
Adding a packagingOptions block may help, please refer to
https://google.github.io/android-gradle-dsl/current/com.android.build.gradle.internal.dsl.PackagingOptions.html
for more information
I tried
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/ASL2.0'
exclude 'internal.kotlin_builtins'
but this doesn't work, I have also tried to Invalidate caches and Restart but to no avail.
I am still learning how to code in android studio so I apologize in advance for my lack of knowledge.
The correct path should be:
exclude 'kotlin/internal/internal.kotlin_builtins'

Duplicate file error at build time ionic EDIT

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

DuplicateFileException m4b + play services 9.0

Error:Execution failed for task ':app:transformResourcesWithMergeJavaResFor'.
com.android.build.api.transform.TransformException: com.android.builder.packaging.DuplicateFileException: Duplicate files copied in APK jsr305_annotations/Jsr305_annotations.gwt.xml
File1:\app\build\intermediates\exploded-aar\google-maps-sdk-m4b\jars\classes.jar
File2:\app\build\intermediates\exploded-aar\com.google.android.gms\play-services-basement\9.0.0\jars\classes.jar
Add below text in build.gradle inside the android{} section to solve the problem.
android {
...
packagingOptions {
exclude 'jsr305_annotations/Jsr305_annotations.gwt.xml'
exclude 'build-data.properties'
}
...
}
If getting more error DuplicateFileException add file with exclude.
Like :
Error
Duplicate files copied in APK jsr305_annotations/Jsr305_annotations.gwt.xml
Solution
exclude 'jsr305_annotations/Jsr305_annotations.gwt.xml'
Adding this to your gradle file will solve your problem:
packagingOptions {
exclude 'jsr305_annotations/Jsr305_annotations.gwt.xml'
}

Android Studio Duplicate files copied in APK META-INF/BCKEY.DSA

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

Duplicate files copied in APK LICENSE (same file)

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.

Categories

Resources