我该如何解决这个问题抛出:Zip​​Exception在编译时就詹金斯的Andr​​oid项目?这个问题、时就、我该、如何解决

2023-09-08 09:44:48 作者:帅气不打烊"

我最近更新了Android SDK中的詹金斯机器上rev13到rev15,只好重做一些我们自定义生成的东西,在的build.xml ,以适应与在rev14所做的更改。我工作了这一点,我的工作站上,并希望一切是桃色检查它。相反,生成失败,出现以下错误:

  -obfuscate:-dex:      [DEX]编译的文件和外部的库转换成/export/home/hudson/jobs/path/to/the/file/classes.dex ...       [DX]       [DX]意外顶级例外:       [DX] java.util.zip.ZipException:错误打开zip文件       [DX]在java.util.zip.ZipFile.open(本机方法)       [DX]在java.util.zip.ZipFile中的<&初始化GT;(ZipFile.java:127)       [DX]在java.util.zip.ZipFile中的<&初始化GT;(ZipFile.java:143)       [DX]在com.android.dx.cf.direct.ClassPathOpener.processArchive(ClassPathOpener.java:206)       [DX]在com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:131)       [DX]在com.android.dx.cf.direct.ClassPathOpener.process(ClassPathOpener.java:109)       [DX]在com.android.dx.command.dexer.Main.processOne(Main.java:418)       [DX]在com.android.dx.command.dexer.Main.processAllFiles(Main.java:329)       [DX]在com.android.dx.command.dexer.Main.run(Main.java:206)       [DX]在com.android.dx.command.dexer.Main.main(Main.java:174)       [DX]在com.android.dx.command.Main.main(Main.java:95)       [DX] 1个错误;中止构建失败在执行这条线出现以下错误:/opt/android-sdk-linux/tool​​s/ant/build.xml:729:在执行这条线出现以下错误:/opt/android-sdk-linux/tool​​s/ant/build.xml:731:在执行这条线出现以下错误:/opt/android-sdk-linux/tool​​s/ant/build.xml:743:/opt/android-sdk-linux/tool​​s/ant/build.xml:249:空返回:1 

我可以成功运行蚂蚁直接作为詹金斯用户具有相同的Andr​​oid SDK,蚂蚁詹金斯工作区目录和JDK的詹金斯使用生成项目。我连斩和粘贴执行行了詹金斯的日志,以确保所有的旋钮和开关都设置相同。所以这是一些关于詹金斯是如何运行这就是问题的生成。

我有詹金斯转储环境作为壳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

我在终端中设置该值,同时从壳运行的版本,并且它以相同的方式,当詹金斯运行事情失败。啊,哈!

问题是,我无法弄清楚如何保持 LD_LIBRARY_PATH 变量从得到一套,或者在一些不会导致此问题指指点点。这不是在詹金斯用户的环境中设置了,我无法找到任何可能的詹金斯配置对它的引用。它设置的值,我才安装的时候改变一个更新的JDK和更新的/ etc /默认/詹金斯 JAVA 价值所以它的明显关系,但遗憾的是,该行为没有任何改善。

我的想法。任何帮助吗?

解决方案

原来,这个问题是,由于涉及利用詹金斯矩阵构建功能的(一个非常不错的功能,顺便)一些配置强辩说库没有把它的 classes.jar 文件,其中父项目期待找到它,导致报告的错误。这基本上是一个找不到文件不这么说。我们仍然不知道什么(如果有的话?)的 LD_LIBRARY_PATH 不得不用它做。

我的同事调整了的build.xml 文件为主营项目和库更有力地同意在何处输出文件要结束了,现在一切再次工作,这让我们的救援。

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. 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. 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. So it's something about how Jenkins is running the build that's the problem.

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.

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. 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. 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. 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.

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. 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.

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.