I've seen a lot of threads about this error, but none that cover my strange scenario. First the basics:
I've got 6 projects, all of which are scaled down test projects that mimic my application's structure and which I'm using just to try to get the build working. Their dependencies are as follows:
- exampleLib is a library that requires no other jars
- contains Widget.java
- exampleLib2 is a library that requires no other jars
- contains Widget2.java
- exampleLibNester is a library that requires exampleLib and exampleLib2
- contains WidgetPartDeux.java
- exampleLibNester2 is a library that requires exampleLib, exampleLib2, and exampleLibNester
- contains WidgetPartDeux2.java
- exampleUser is an application that requires exampleLib, exampleLib2, exampleLibNester, and exampleLibNester2
- contains TheActivity.java
- exampleTest is a test application that instruments exampleUser and requires exampleLib, exampleLib2, and exampleLibNester
- contains WidgetTest.java
When I build these applications using ant locally on windows they run fine and I can use install test
to run the tests. When I try to build them on my CI server, which is running linux, I get the dreaded "already added" error message.
-dex:
[dex] Converting compiled files and external libraries into /apps/pos360/jenkins/.hudson/jobs/James-Test/exampleLibUser/bin/classes.dex...
[dx]
[dx] UNEXPECTED TOP-LEVEL EXCEPTION:
[dx] java.lang.IllegalArgumentException: already added: Lcom/example/nester/WidgetPartDeux;
[dx] at com.android.dx.dex.file.ClassDefsSection.add(ClassDefsSection.java:123)
[dx] at com.android.dx.dex.file.DexFile.add(DexFile.java:163)
[dx] at com.android.dx.command.dexer.Main.processClass(Main.java:486)
[dx] at com.android.dx.command.dexer.Main.processFileBytes(Main.java:455)
[dx] at com.android.dx.command.dexer.Main.access$400(Main.java:67)
[dx] at com.android.dx.command.dexer.Main$1.processFileBytes(Main.java:394)
[dx] at com.android.dx.cf.direct.ClassPathOpener.processArchive(ClassPathOpener.java:245)
[dx] at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:131)
[dx] at com.android.dx.cf.direct.ClassPathOpener.process(ClassPathOpener.java:109)
[dx] at com.android.dx.command.dexer.Main.processOne(Main.java:418)
[dx] at com.android.dx.command.dexer.Main.processAllFiles(Main.java:329)
[dx] at com.android.dx.command.dexer.Main.run(Main.java:206)
[dx] at com.android.dx.command.dexer.Main.main(Main.java:174)
[dx] at com.android.dx.command.Main.main(Main.java:91)
[dx]
[dx] UNEXPECTED TOP-LEVEL EXCEPTION:
[dx] java.lang.IllegalArgumentException: already added: Lcom/example/lib/Widget;
[dx] at com.android.dx.dex.file.ClassDefsSection.add(ClassDefsSection.java:123)
[dx] at com.android.dx.dex.file.DexFile.add(DexFile.java:163)
[dx] at com.android.dx.command.dexer.Main.processClass(Main.java:486)
[dx] at com.android.dx.command.dexer.Main.processFileBytes(Main.java:455)
[dx] at com.android.dx.command.dexer.Main.access$400(Main.java:67)
[dx] at com.android.dx.command.dexer.Main$1.processFileBytes(Main.java:394)
[dx] at com.android.dx.cf.direct.ClassPathOpener.processArchive(ClassPathOpener.java:245)
[dx] at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:131)
[dx] at com.android.dx.cf.direct.ClassPathOpener.process(ClassPathOpener.java:109)
[dx] at com.android.dx.command.dexer.Main.processOne(Main.java:418)
[dx] at com.android.dx.command.dexer.Main.processAllFiles(Main.java:329)
[dx] at com.android.dx.command.dexer.Main.run(Main.java:206)
[dx] at com.android.dx.command.dexer.Main.main(Main.java:174)
[dx] at com.android.dx.command.Main.main(Main.java:91)
[dx] 2 errors; aborting
I can look in the classes.jar files and see that exampleLibNester2 is pulling those classes into its jars, but I don't know how to prevent it from doing that nor why it does it on the linux box but not the windows one. Both SDKs have been updated to the latest version.