Duplicate LICENCE & NOTICE files in v2.2.0 make Android packaging step fails #214

Closed
thierryd opened this Issue Apr 25, 2013 · 16 comments

5 participants

@thierryd

The two files LICENCE and NOTICE file where added in the jar file of the v.2.2.0 release. Unfortunately, Android has a limitation that duplicate files cannot exists while packaging the app. Since jackson-core already has these files, the packaging fails.

One workaround is to rename the files or move them to another folder.


[Updated] Just for those searching the same problem on Google, the Eclipse error message is "Error generating final archive: Found duplicate file for APK"

@cowtowncoder
FasterXML, LLC member

Thank you for reporting this problem!

This is very unfortunate limitation wrt Android... since (AFAIK) convention is to leave these at root level of jars.
I'll see how to resolve this; need to discuss it on dev list.

@cowtowncoder
FasterXML, LLC member

One question: since pretty much all Apache Licensed jars should have these same files, how do those work?

One workaround/solution that might be relevant is this:

http://stackoverflow.com/questions/8103863/duplicate-file-when-deploying-apk

which seems to just allow duplicates.

@cowtowncoder
FasterXML, LLC member

and from another similar question, looks like one would do:

Finally I found it! There is indeed one option, which does what I need in the maven-android-plugin.
  <extractDuplicates>true</extractDuplicates>

(from https://groups.google.com/forum/?fromgroups=#!topic/maven-android-developers/QjbzoaC1Q3k)

@thierryd

The "extractDuplicates" workaround works for Maven, but not with the Eclipse builder. :(

I have around 15 other JARs. Most do not include license. For example "commons-io", "commons-lang", "commons-collection", "guice", "guava", "android-support" and "jsr305". Each of these JAR files does not include a licence.

I have checked and the commons-* libraries are distributed in zip files that contains the license and the JAR file.

I have another one (joda-time - a popular date/time library) that have LICENCE.txt and NOTICE.txt under \META-INF.

Thanks! :)

@cowtowncoder
FasterXML, LLC member

Sad thing is that addition of LICENSE was due to a user request; big Open Source companies / projects (like Debian I think) are big on having this information included.
I'll see what can be done here to satisfy conflicting requirements.

@BobKerns
@cowtowncoder
FasterXML, LLC member

Ok. Looking at multiple jars by ASF projects (Avro, Ant, commons-compress), looks like they actually include LICENSE and NOTICE files under META-INF. Maybe tools know that these files can collide freely?
I could make this change easily, and assume it to be sort of best practice anyway.

Would it be possible for you to test this locally, to verify whether this would resolve the issue?

@cowtowncoder
FasterXML, LLC member

This (using per-package location) could work, as long as we can figure out how to make Maven build do that.

But first I would like to see if APK tools at least had sensible logic wrt META-INF -- it is possible (but not guaranteed) that entries in there would not conflict.

@cowtowncoder cowtowncoder was assigned Apr 26, 2013
@thierryd

I added commons-compress to my project and it builds successfully. Even though the joda-time library also have the same file.

So I did some investigation and moved the LICENSE and NOTICE file under \META-INF for both jackson-core and jackson-databind and the build works now. It appears that the duplicate file problem can be fixed if those file are moved under \META-INF.

It make sense since anything else not under \META-INF is treated like code or asset of this code and Android packages it into the app.... err... package. Hence the duplicate file problem! :)

@prb
FasterXML, LLC member
@cowtowncoder
FasterXML, LLC member

I think for now we can just move these under META-INF directly, since that seems to be "the Apache way".
So unless there's other reason to do that, let's postpone fancier tricks.

@thierryd thank you for checking this out -- I'll fix the issue next.

@cowtowncoder
FasterXML, LLC member

Fixed core jars that had these files added; should work better for 2.2.1.

@friederbluemle

Hi, when will version 2.2.1 be available? I'm currently facing the same issues with the duplicate file error on Android.
Thanks.

@cowtowncoder
FasterXML, LLC member

It is a careful balancing act -- since releasing new set of patch versions is significant amount of work, I would hope to find out all critical 2.2.0 issues. But at the same time, already fixed critical things should go out ASAP.

At practical level I may have to do it over this weekend -- I will be travelling next week, and couldn't do release.
So either this or next weekend, I think.

@friederbluemle

Okay cool, it would be great if you could do it this weekend. Until then I will have to use 2.1.4
Thanks for this awesome library!

@cowtowncoder
FasterXML, LLC member

Understood -- feels silly, given that 2.2 otherwise should be nice upgrade esp. on Android.

Thanks!

@fge fge added a commit to fge/jackson-coreutils that referenced this issue Mar 12, 2014
@fge fge Fix conflicts with Android's APK build
It doesn't handle duplicates correctly. Problem description and fix adapted from
FasterXML/jackson-databind#214.
046c100
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment