gpt4 book ai didi

java - Build project containing lib project 包含 lib project with ant

转载 作者:行者123 更新时间:2023-11-29 06:05:39 25 4
gpt4 key购买 nike

我们的项目结构如下:

sharedlib (lib-project, containing classes, that are useful in many apps)
-> main-project (lib-project, containing everything to run the app)
---> 2 branded projects (with different icons/styles for the main-project)

在 Eclipse 中,主项目是一个库项目,引用 Android 设置中的共享库,两个品牌项目将主项目引用为库。

如果我们在 Eclipse 下编译品牌项目一切正常,但我们无法让 ant build (sdk tools r16) 工作。我们尝试了几种将库项目添加到品牌项目中的变体。我们得到一个错误,找不到库项目的类文件或以下 dex 错误:

-dex:
[echo] Converting compiled files and external libraries into .../bin/classes.dex...
[apply]
[apply] UNEXPECTED TOP-LEVEL EXCEPTION:
[apply] java.lang.IllegalArgumentException: already added: L.../android/android/lib/R$attr;
[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:372)
[apply] at com.android.dx.command.dexer.Main.processFileBytes(Main.java:346)
[apply] at com.android.dx.command.dexer.Main.access$400(Main.java:59)
[apply] at com.android.dx.command.dexer.Main$1.processFileBytes(Main.java:294)
[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:313)
[apply] at com.android.dx.command.dexer.Main.processAllFiles(Main.java:233)
[apply] at com.android.dx.command.dexer.Main.run(Main.java:185)
[apply] at com.android.dx.command.dexer.Main.main(Main.java:166)
[apply] at com.android.dx.command.Main.main(Main.java:90)
[apply] 1 error; aborting

所以问题是我们的库根本没有添加或添加了两次。任何想法,ant 构建文件必须如何构建品牌项目?

最佳答案

我也遇到了同样的错误,Google 搜索将我带到了以下链接,它解决了我的问题。

Davlik bug? UNEXPECTED TOP-LEVEL EXCEPTION: java.lang.IllegalArgumentException: already added: [classXXX]

以下是对问题的解释,摘自链接:

The (admittedly ugly) message is trying to tell you that you have in
fact managed to include two classes with the same fully-qualified name
(package + name) in your dx commandline. If you are using dx
implicitly via the Eclipse plugin (looks like you are), then you have
somehow managed to add the same classes twice in the Eclipse UI.

在这里,您可能已经在类路径中添加了两次 L.../android/android/lib/R 类。您的类路径中似乎有两个或更多版本的具有相同包名的自动生成类 R。检查应用程序和库以确保类 R 已放置在所有应用程序和库中的不同包下。

希望这有帮助:)

关于java - Build project containing lib project 包含 lib project with ant,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8615676/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com