问题描述
我的 Android 项目使用了几个标记为 Android 库的 git 子模块.这些子模块都对 ORMlite Android jar 有不同的用途,因此 ORMlite jar 包含在它们的 libs
目录中.Eclipse 正确处理了这种情况:它在 dex
处理期间包含一次 ORMlite jars 并生成有效的 .apk,但是当我通过 ant debug
运行构建时,我得到:
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)
有没有办法让同一个 JAR 的多个副本散布在多个库中?是否有我可以更改的 Ant 构建设置以使其正常工作?
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?
推荐答案
我通过创建第三个 Android 项目解决了我的问题,其中仅包含其他两个项目所依赖的 ORMlite JAR.
I solved my problem by creating a third Android project with only the ORMlite JAR in it that the two other projects depended on.
这篇关于Android 构建可在 Eclipse 中运行,但不适用于 Ant(“已添加")的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!