My Android project uses several git submodules marked as Android Libraries. These submodules all have different uses of the ORMlite Android jars and thus have the ORMlite jars included in their libs
directory. Eclipse handles this situation correctly: it includes the ORMlite jars once during the dex
processing and generates a valid .apk, but when I run a build via ant debug
, I get:
[echo] Converting compiled files and external libraries into /home/webedit/.hudson/jobs/xyz/workspace/bin/classes.dex...
[apply]
[apply] UNEXPECTED TOP-LEVEL EXCEPTION:
[apply] java.lang.IllegalArgumentException: already added: Lcom/j256/ormlite/android/AndroidCompiledStatement;
[apply] at com.android.dx.dex.file.ClassDefsSection.add(ClassDefsSection.java:123)
[apply] at com.android.dx.dex.file.DexFile.add(DexFile.java:143)
[apply] at com.android.dx.command.dexer.Main.processClass(Main.java:338)
[apply] at com.android.dx.command.dexer.Main.processFileBytes(Main.java:315)
[apply] at com.android.dx.command.dexer.Main.access$100(Main.java:56)
[apply] at com.android.dx.command.dexer.Main$1.processFileBytes(Main.java:266)
[apply] at com.android.dx.cf.direct.ClassPathOpener.processArchive(ClassPathOpener.java:244)
[apply] at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:130)
[apply] at com.android.dx.cf.direct.ClassPathOpener.process(ClassPathOpener.java:108)
[apply] at com.android.dx.command.dexer.Main.processOne(Main.java:284)
[apply] at com.android.dx.command.dexer.Main.processAllFiles(Main.java:220)
[apply] at com.android.dx.command.dexer.Main.run(Main.java:176)
[apply] at com.android.dx.command.dexer.Main.main(Main.java:157)
[apply] at com.android.dx.command.Main.main(Main.java:89)
Is there any way to have multiple copies of the same JAR sprinkled across multiple libraries? Is there an Ant build setting I can change to get this to work?
i got the same problem using maven because it correctly added the ormlite-core-jarfile, which contains the packages and classes as the core-jar with a few additional classes.
I added an exclusion and now it works
<dependency>
<groupId>com.j256.ormlite</groupId>
<artifactId>ormlite-android</artifactId>
<version>4.9</version>
<exclusions>
<exclusion>
<groupId>com.j256.ormlite</groupId>
<artifactId>ormlite-core</artifactId>
</exclusion>
</exclusions>
</dependency>
I solved my problem by creating a third Android project with only the ORMlite JAR in it that the two other projects depended on.
My problem was that all jars in any ./libs folder were included, not just the ones as specified in my eclipse .classpath. So I had some duplicates laying around there. I just needed to clean up my ./libs. You can find out what ant is all including in its "classpath" by running "ant -v debug", somewhere in the top half of the output.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With