6

我有一个项目可以在 Eclipse 中构建,但在执行“ant debug”时会抛出 ZipException。输出如下(不包括路径和项目名称)

    -dex:
      [dex] Converting compiled files and external libraries into /home/.../Android/[folder]/bin/classes.dex...
       [dx] 
       [dx] UNEXPECTED TOP-LEVEL EXCEPTION:
       [dx] java.util.zip.ZipException: error in opening zip file
       [dx]     at java.util.zip.ZipFile.open(Native Method)
       [dx]     at java.util.zip.ZipFile.<init>(ZipFile.java:131)
       [dx]     at java.util.zip.ZipFile.<init>(ZipFile.java:148)
       [dx]     at com.android.dx.cf.direct.ClassPathOpener.processArchive(ClassPathOpener.java:206)
       [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:95)
       [dx] 1 error; aborting

BUILD FAILED
/home/.../android-sdk-linux_x86/tools/ant/build.xml:818: The following error occurred while executing this line:
/home/.../android-sdk-linux_x86/tools/ant/build.xml:820: The following error occurred while executing this line:
/home/.../android-sdk-linux_x86/tools/ant/build.xml:832: The following error occurred while executing this line:
/home/.../android-sdk-linux_x86/tools/ant/build.xml:278: null returned: 1

该项目引用了一个库项目,该库项目引用了另一个库项目。所以

项目 A -> 项目 B -> 项目 C

对我来说,奇怪的部分是从 Eclipse 安装一切正常,但我需要能够从 Ant 构建项目。

我已经用谷歌搜索了没有成功的答案。SO中的类似问题没有帮助

在 Jenkins 上编译 Android 项目时如何修复此 ZipException?

配置 ant 以运行单元测试。图书馆应该在哪里?类路径应该如何配置?避免 ZipException

4

2 回答 2

1

我在 dexing 时遇到了同样的错误。我发现.jar包含的 android 库项目中的损坏文件导致了此问题。

.jar修复包含的 android 库项目中的损坏文件修复了该问题。

希望这对某人有帮助!=D

于 2012-10-16T21:51:25.740 回答
1

我在我的项目中遇到了同样的问题。我发现使用调试标志“-d”运行 ant 会转储诊断问题所需的信息。Ant 会将确切的 dx 命令转储到控制台,它看起来像这样:

Execute:Java13CommandLauncher: Executing '/Users/cliff/android-sdk-macosx/platform-tools/dx' with arguments:
'--dex'
'--output'
'/Users/cliff/Src/myproject/myproject-app/bin/classes.dex'
'/Users/cliff/Src/myproject/myproject-app/bin/classes'
'/Users/cliff/Src/myproject/myproject-config/bin/classes.jar'

就我而言,其中一个依赖项目 (myproject-config) 尚未构建,因此缺少 myproject-config/bin/classes.jar。我走进 myproject-config/ 文件夹,运行“ant debug”然后返回并成功构建我的项目

于 2012-11-29T20:44:59.433 回答