Duplicate files at the same path inside the APK, when adding jar

5,224 views
Skip to first unread message

Lars Poeschel

unread,
Mar 29, 2011, 12:33:07 PM3/29/11
to maven-androi...@googlegroups.com
Hello!

I try to build the i-jetty webserver using maven-android-plugin.
I created a set of pom.xml files for this and I got the above error
building it. I first thought, that the error is because of some apklibs
contain the same references. So I copied all the sourcecode together in
one src dir and modified the relevant pom.xml but still get the same error.
I don't know which files are duplicate. I tried with 2.9.0-beta-1,
2.9.0-beta-2 and even built an 2.9.0-SNAPSHOT but nothing works. What
can I do to find my mistake ? Can I do something to help debugging ?

Thanks,
Lars


build.txt
pom.xml

Manfred Moser

unread,
Mar 29, 2011, 12:10:05 PM3/29/11
to maven-androi...@googlegroups.com
Wanna share the pom files in github or somewhere so we can have a look?

> --
> You received this message because you are subscribed to the Google Groups
> "Maven Android Developers" group.
> To post to this group, send email to
> maven-androi...@googlegroups.com.
> To unsubscribe from this group, send email to
> maven-android-deve...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/maven-android-developers?hl=en.
>
>

Lars Poeschel

unread,
Mar 29, 2011, 2:52:13 PM3/29/11
to maven-androi...@googlegroups.com

On 29 Mrz., 18:10, "Manfred Moser" <manf...@mosabuam.com> wrote:
> Wanna share the pom files in github or somewhere so we can have a look?

I already attached the pom.xml to the first post for the case that
i-jetty-server and i-jetty-ui sources are mixed to one single directory.

Here now comes the case for the original i-jetty directory structure.
This archive contains the needed poms and resources for i-jetty-server.
Simply extract in current i-jetty-SNAPSHOT.

Lars

pomfiles.tar

Lars Poeschel

unread,
Mar 30, 2011, 8:45:25 AM3/30/11
to maven-androi...@googlegroups.com

I digged a bit deeper and found one problem:
All of the org.eclipse.jetty.jetty-*.jar s included from i-jetty contain
a file about.html containing the license. It seems that android's
ApkBuilder.java can not handle this. It thinks that files are duplicate.
Has someone an idea how to handle that issue best ?

Thanks, Lars

Manfred Moser

unread,
Mar 30, 2011, 12:37:38 PM3/30/11
to maven-androi...@googlegroups.com
--
Manfred Moser
http://www.mosabuam.com
skype mosabua, twitter.com/mosabua
http://www.linkedin.com/in/manfredmoser

Not sure.. worst case you can patch the plugin code and add a new
option that allows to exclude files of certain name patterns from the
exploded dependencies..

Not even sure if that is not already there .. check out the plugin
options.

manfred

Joakim Erdfelt

unread,
Mar 30, 2011, 4:56:01 PM3/30/11
to maven-androi...@googlegroups.com, Manfred Moser
I"m on the hook to migrate the i-jetty build when I get time. (but not likely until mid/end of April.

Busy,
- Joakim

Lars Poeschel

unread,
Mar 31, 2011, 6:32:33 AM3/31/11
to maven-androi...@googlegroups.com
Am 30.03.2011 18:37, schrieb Manfred Moser:
> Not sure.. worst case you can patch the plugin code and add a new
> option that allows to exclude files of certain name patterns from the
> exploded dependencies.. Not even sure if that is not already there ..
> check out the plugin options.

I found no option that does that - at least not in the maven-android-plugin.
Doing this would be very difficult. I attached a stacktrace to
illustrate that.

[ERROR] Cannot add resources from jar
com.android.sdklib.build.DuplicateFileException: Duplicate files at the
same path inside the APK
at
com.android.sdklib.build.ApkBuilder$JavaAndNativeResourceFilter.checkEntry(ApkBuilder.java:121)
at
com.android.sdklib.internal.build.SignedJarBuilder.writeZip(SignedJarBuilder.java:225)
at
com.android.sdklib.build.ApkBuilder.addResourcesFromJar(ApkBuilder.java:556)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:616)
at
com.jayway.maven.plugins.android.phase09package.ApkBuilder.addResourcesFromJar(ApkBuilder.java:266)
at
com.jayway.maven.plugins.android.phase09package.ApkMojo.doAPKWithAPKBuilder(ApkMojo.java:307)
at
com.jayway.maven.plugins.android.phase09package.ApkMojo.createApkFile(ApkMojo.java:196)
at
com.jayway.maven.plugins.android.phase09package.ApkMojo.execute(ApkMojo.java:169)
at
org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:490)
at
org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:694)
at
org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalWithLifecycle(DefaultLifecycleExecutor.java:556)
at
org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(DefaultLifecycleExecutor.java:535)
at
org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures(DefaultLifecycleExecutor.java:387)
at
org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(DefaultLifecycleExecutor.java:348)
at
org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:180)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:328)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:138)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:362)
at
org.apache.maven.cli.compat.CompatibleMain.main(CompatibleMain.java:60)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:616)
at
org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:315)
at org.codehaus.classworlds.Launcher.launch(Launcher.java:255)
at
org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430)
at org.codehaus.classworlds.Launcher.main(Launcher.java:375)


The last step that is controled by the maven-android-plugin is

com.jayway.maven.plugins.android.phase09package.ApkBuilder.addResourcesFromJar(ApkBuilder.java:266)

Here a whole jar file is handed over to google's SDK Tools, there the
depackaging takes place. The relevant class is:
com/android/sdklib/build/ApkBuilder.java. There some checks take place
(for duplicate files for example) and there are already some exceptions
from this (for example META-INF directory or .cvsignore files and so
on). Here would be the best place to handle this issue. But I think I
never get google to exclude "about.html" in their SDK.
The other, dirty way would be to de-jar every jar in
maven-andriod-plugin, look for about.html, exclude it and re-jar it and
then hand it over to google's ApkBuilder. Would a patch that does this
have a chance to get included ?
What do you think would be the best way ?
As a workaround I remove the about.html's from every relevant jar in my
local maven repository by hand at the moment.

Regards,
Lars

Lars Poeschel

unread,
Mar 31, 2011, 9:18:15 AM3/31/11
to maven-androi...@googlegroups.com

Heureka!

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

Thank you!

Manfred Moser

unread,
Mar 31, 2011, 12:03:10 PM3/31/11
to maven-androi...@googlegroups.com
> Am 31.03.2011 12:32, schrieb Lars Poeschel:
>> Am 30.03.2011 18:37, schrieb Manfred Moser:
..

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


Ha.. sweet. I thought I saw that problem and a solution for it before..

Eric Turley

unread,
Apr 17, 2013, 3:58:17 PM4/17/13
to maven-androi...@googlegroups.com
No - I never got it working.
I abandoned this path for a completely different means which is no longer applicable to this thread.
:(

On Wednesday, April 17, 2013 10:49:35 AM UTC-5, Muhi Masoud wrote:
Eric Turley did you ever get this working I have the same problem.
Thanks

Matt Wolfe

unread,
Apr 23, 2013, 3:18:02 PM4/23/13
to maven-androi...@googlegroups.com
All the sudden I'm getting this problem as well.
I have a project like so
Project A depends on Project B, Project B depends on Project C.

B and C  both have NDK libs but A does not have any (but does use C's ndk libs).

This worked up until recently. Weird that it didn't stop working at the same time as I upgraded to 3.5.3. It took several days and a bunch of builds before the problem came up. I think eclipse must have cleared out something.

I noticed that I used to use <clearNativeArtifacts>true</clearNativeArtifacts>
but that caused my build to fail saying that the so was missing (at build time). Then I set that to false and now the build works up until the last step when we get the duplicate error.

Any suggestions?

Jianing Zhang

unread,
Feb 25, 2014, 7:42:04 PM2/25/14
to maven-androi...@googlegroups.com
Hey guys,

I ran into the same problem, tried with <extractDuplicates>true</extractDuplicates> , didn't work out. Did any of you guys figure out how to solve this issue? 

Any comments? Thanks!

Guang Han

unread,
Feb 25, 2014, 11:54:59 PM2/25/14
to maven-androi...@googlegroups.com
you might add some resource files multiple times. double check maven-resource-plugin outputs to see if some resource files got copied more than once.


--
You received this message because you are subscribed to the Google Groups "Maven Android Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to maven-android-deve...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply all
Reply to author
Forward
0 new messages