简体   繁体   English

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

[英]How do I fix this ZipException while compiling an Android project on Jenkins?

I recently updated the Android SDK on the Jenkins machine to rev15 from rev13, and had to redo some of our custom build stuff in build.xml to fit in with the changes made in rev14. 我最近将Jenkins机器上的Android SDK从rev13更新到rev15,并且不得不在build.xml重做我们的一些自定义构建内容以适应rev14中的更改。 I worked this out on my workstation, and checked it in expecting everything to be peachy. 我在我的工作站上完成了这项工作,并检查了它,期待一切都是好的。 Instead, the build fails with the following error: 相反,构建失败并出现以下错误:

-obfuscate:

-dex:
      [dex] Converting compiled files and external libraries into /export/home/hudson/jobs/path/to/the/file/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:127)
       [dx]     at java.util.zip.ZipFile.<init>(ZipFile.java:143)
       [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
/opt/android-sdk-linux/tools/ant/build.xml:729: The following error occurred while executing this line:
/opt/android-sdk-linux/tools/ant/build.xml:731: The following error occurred while executing this line:
/opt/android-sdk-linux/tools/ant/build.xml:743: The following error occurred while executing this line:
/opt/android-sdk-linux/tools/ant/build.xml:249: null returned: 1

I can successfully build the project by running ant as the Jenkins user directly in the Jenkins workspace directory with the same Android SDK, Ant, and JDK that Jenkins is using. 我可以使用Jenkins正在使用的相同Android SDK,Ant和JDK直接在Jenkins工作区目录中运行ant作为Jenkins用户来成功构建项目。 I even cut-and-paste the execution line out of the Jenkins log to ensure that all the knobs and switches are set the same. 我甚至将执行线从Jenkins日志中剪切并粘贴,以确保所有旋钮和开关设置相同。 So it's something about how Jenkins is running the build that's the problem. 所以这是关于Jenkins如何运行构建问题的问题。

I had Jenkins dump the environment as a "shell exec" step of the build, and I see that the LD_LIBRARY_PATH variable is set. 我让Jenkins将环境转储为构建的“shell exec”步骤,我看到LD_LIBRARY_PATH变量已设置。

LD_LIBRARY_PATH=/u0/jdk1.6.0_29/jre/lib/i386/server:/u0/jdk1.6.0_29/jre/lib/i386:/u0/jdk1.6.0_29/jre/../lib/i386

I set this value in my terminal while running the build from the shell, and it fails in the same way as when Jenkins runs things. 我在从终端运行构建时在终端中设置了这个值,它的失败方式与Jenkins运行时的方式相同。 Ah-ha! 啊,哈!

The problem is that I can't figure out how to keep the LD_LIBRARY_PATH variable from getting set, or pointing at something that won't cause this problem. 问题是我无法弄清楚如何保持LD_LIBRARY_PATH变量不被设置,或指向不会导致此问题的事情。 It's not set in the Jenkins user's environment, and I can't find anything that might be a reference to it in the Jenkins configuration. 它没有在Jenkins用户的环境中设置,我在Jenkins配置中找不到任何可能引用它的东西。 The value it set did change when I installed an updated JDK and updated the JAVA value in /etc/defaults/jenkins so it's clearly related, but unfortunately, the behavior didn't improve any. 当我安装更新的JDK并更新/etc/defaults/jenkinsJAVA值时,它设置的值确实发生了变化,因此它显然是相关的,但不幸的是,这种行为没有改善。

I'm out of ideas. 我没有想法。 Any help? 有帮助吗?

The problem turned out to be that due to some configuration chicanery involved in making use of the Jenkins matrix build feature (a very nice feature, by the way) that a library was not putting its classes.jar file where the parent project was expecting to find it, causing the reported error. 问题结果是由于一些配置chicanery参与使用Jenkins矩阵构建功能(顺便说一句非常好的功能),库没有将其classes.jar文件放在父项目所期望的位置找到它,导致报告错误。 That was basically a "file not found" that doesn't say so. 这基本上是一个“未找到的文件”,并没有这么说。 We're still not sure what (if anything?) the LD_LIBRARY_PATH had to do with it. 我们仍然不确定LD_LIBRARY_PATH与它有什么关系(如果有的话)。

My colleague tweaked the build.xml file for the main project and the library to more forcefully agree on where output files are going to end up, and now everything works again, much to our relief. 我的同事调整了主项目和库的build.xml文件,以便更有力地同意输出文件最终的位置,现在一切都再次起作用,这让我们感到宽慰。

I had the same problem. 我有同样的问题。 I was building on Jenkins and jar was getting copied into libs incorrectly. 我在Jenkins上构建,jar被错误地复制到库中。

I am using the Jenkins Copy Artifacts Plugin to grab a common library jar and copy it into libs/. 我正在使用Jenkins Copy Artifacts插件来获取一个公共库jar并将其复制到libs /中。 I got the error when I did not use the "Flatten Directories" option. 当我没有使用“Flatten Directories”选项时,我收到了错误。 Once I just had the jar in the libs directory everything was back to normal. 一旦我在libs目录中使用jar,一切都恢复正常。

Hopefully this saves someone the headache! 希望这能让人头疼!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在启动Android LibGDX项目时修复NoClassDefFoundError? - How do I fix a NoClassDefFoundError while launching Android LibGDX Project? 如何在android中编译项目时修复这些无法找到依赖项的错误? - How can I fix these errors about not being able to find dependencies when compiling project in android? 如何在运行 expo build android 时修复此错误? - How do I fix this error while running expo build android? Flutter,android项目在编译时遇到错误 - Flutter, android project runs into an error while compiling eclipse中的Android应用项目有很多打包错误,如何解决? - Android app project in eclipse has many package errors, how do I fix this? 我如何修复项目同步失败并在 android studio 3.2 中出现“无法解决:multidex”错误 - How do i fix project sync failed with "Failed to resolve: multidex" error in android studio 3.2 运行“ cordova run android”时,如何解决“评估项目&#39;:CordovaLib&#39;时出现问题。” - How do I fix “A problem occurred evaluating project ':CordovaLib'.” when running 'cordova run android' 如何使用 jenkins 构建 android 项目? - How to build android project with jenkins? Android Studio ..我该如何解决? - android studio .. how do i fix this? 如何修复Android中的glUseProgram错误 - How do I fix glUseProgram error in Android
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM