Duplicate files copied in APK LICENSE (same file) - android

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.

Related

Android More than one file was found with OS independent path 'google/protobuf/type.proto'

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.

How to exclude package-info.java files from dex?

I have a multi-module Android application and when I build the release APK, I get this dex error:
java.util.concurrent.ExecutionException: com.android.dex.DexException: Multiple dex files define Lcom/XX/package-info;
I do of course have a package-info file in all my modules and they all have the same name.
Why does dex even care about package-info files, and how can I configure it to ignore them?
Note: I do NOT want to enable multi-dex
The solution is to exclude the package-info files from the jar files.
Example code to use in build.gradle files
for java-modules:
jar {
exclude('com/**/package-info.*')
}
for android-modules:
android {
sourceSets.main.java.filter.exclude 'com/**/package-info.*'
}
Works with:
Android Studio 3.0 Canary 5
Gradle 4.1-milestone-1
Android gradle plugin: 3.0.0-alpha5
Note: you can of course only then exclude the package-info files if they don't contribute to your build!
e.g. when you use immutables style-configuration in your package-info file then you cannot exclude the files from the build, because then the names of the generated files may change!
Try with using packagingOptions inside android tag in build.gradle for app module.
packagingOptions {
exclude 'META-INF/DEPENDENCIES.txt'
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/dependencies.txt'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/LICENSE'
exclude 'META-INF/license.txt'
exclude 'META-INF/LGPL2.1'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/NOTICE'
exclude 'META-INF/notice.txt'
}
More: Packaging

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

Android Studio Gradle Build Error - Joda Time

I added the latest Joda Time jar into my libs folder and added the library. when trying to run I get the following error:
Error:Execution failed for task ':Selfies:packageDebug'.
> Duplicate files copied in APK META-INF/LICENSE.txt
File 1: C:\Users\Dominic\Desktop\selfieapp\Selfies\Selfies\libs\commons-io-2.4.jar
File 2: C:\Users\Dominic\Desktop\selfieapp\Selfies\Selfies\libs\joda-time-2.8.1.jar
Not too sure what this means and how to fix it. Any help would be great!
Update yout build.gradle like this:
android {
...
packagingOptions {
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
}
}
you can exclude this file with packagingOptions in your build.gradle - but you should also have a look into joda-time-android or even better https://github.com/JakeWharton/ThreeTenABP

Android Proguard build Duplicate Zip

In my android application i have multiple third party libraries in libs folder
ex -: httpcore-4.2.4.jar , httpmime-4.2.5.jar,twitter4j-core-4.0.1.jar
these libraries are not duplicated and i'm pretty sure with that , but when i create the proguard release i get this error
(Duplicate zip entry [twitter4j-core-4.0.1.jar:META-INF/MANIFEST.MF])
.... (This error occurs for all of the library(libs)
I refereed this link to overcome with issue , i tried every option of it , but no luck with that ,
Proguard warnings "can't write resource [META-INF/MANIFEST.MF] (Duplicate zip entry)"
Is there any way to specify filters on the input jar
Your libraries are not duplicated, but some info files inside of several libraries are.
The best solution is to include in your build.gradle. inside the "android" section something like this:
android{
packagingOptions {
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/DEPENDENCIES.txt'
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/LICENSE'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LGPL2.1'
}
}
By the error message that you included here I will guess that adding this exclude will solve your problem:
exclude "META-INF/MANIFEST.MF"

Categories

Resources