Android - Proguard返回错误代码1

问题描述:

我希望我的应用程序受到progaurd保护。为此,我去将向您介绍一些教程,职位和从this帖最后我才知道,我只能这样做:Android - Proguard返回错误代码1

If you're using ADT 17 or newer, the documentation is slightly inaccurate. The generated file is proguard-project.txt and will be in the root directory of your project. 

To enable Proguard, you will need to ignore the "do not modify" warning in project.properties and uncomment the following line: 

proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt 

uncommeting上述建议行我试图出口未签名应用后。但有一个出口错误说progaurd returned error with code 1。当我点击了错误对话框中的详细信息按钮,我得到了如下图所示的错误日志:

Proguard returned with error code 1. See console 
Proguard Error 1 
Output: 
     You should check if you need to specify additional program jars. 
Warning: can't write resource [META-INF/MANIFEST.MF] (Duplicate zip entry [acra- 

4.4.0.jar:META-INF/MANIFEST.MF]) 
Warning: can't write resource [META-INF/MANIFEST.MF] (Duplicate zip entry 

[libGoogleAnalyticsV2.jar:META-INF/MANIFEST.MF]) 
Warning: can't write resource [META-INF/MANIFEST.MF] (Duplicate zip entry [google-play- 

services_lib.jar:META-INF/MANIFEST.MF]) 
Warning: can't write resource [META-INF/MANIFEST.MF] (Duplicate zip entry 

[vpilibrary.jar:META-INF/MANIFEST.MF]) 
Warning: can't write resource [META-INF/MANIFEST.MF] (Duplicate zip entry 

[abslibrary.jar:META-INF/MANIFEST.MF]) 
java.io.IOException: Can't write [C:\Users\SURESH\AppData\Local\Temp 

\android_6223056648746329994.jar] (Can't read [C:\Users\SURESH\Desktop\ActionBarSherlock- 

4.2.0\ABSlibrary\bin\abslibrary.jar] (Unexpected end of ZLIB input stream)) 
    at proguard.OutputWriter.writeOutput(OutputWriter.java:264) 
    at proguard.OutputWriter.execute(OutputWriter.java:160) 
    at proguard.ProGuard.writeOutput(ProGuard.java:372) 
    at proguard.ProGuard.execute(ProGuard.java:153) 
    at proguard.ProGuard.main(ProGuard.java:492) 
Caused by: java.io.IOException: Can't read [C:\Users\SURESH\Desktop\ActionBarSherlock- 

4.2.0\ABSlibrary\bin\abslibrary.jar] (Unexpected end of ZLIB input stream) 
    at proguard.InputReader.readInput(InputReader.java:230) 
    at proguard.InputReader.readInput(InputReader.java:200) 
    at proguard.OutputWriter.writeOutput(OutputWriter.java:253) 
    ... 4 more 
Caused by: java.io.EOFException: Unexpected end of ZLIB input stream 
    at java.util.zip.InflaterInputStream.fill(InflaterInputStream.java:223) 
    at java.util.zip.InflaterInputStream.read(InflaterInputStream.java:141) 
    at java.util.zip.ZipInputStream.read(ZipInputStream.java:154) 
    at java.util.zip.ZipInputStream.closeEntry(ZipInputStream.java:100) 
    at java.util.zip.ZipInputStream.getNextEntry(ZipInputStream.java:78) 
    at proguard.io.JarReader.read(JarReader.java:58) 
    at proguard.io.DirectoryPump.readFiles(DirectoryPump.java:65) 
    at proguard.io.DirectoryPump.pumpDataEntries(DirectoryPump.java:53) 
    at proguard.InputReader.readInput(InputReader.java:226) 
    ... 6 more 

任何想法,为什么会出现这种情况?我正确配置progaurd或错过了步骤?

的根本原因是在堆栈跟踪上市:

Caused by: java.io.IOException: Can't read [C:\Users\SURESH\Desktop\ActionBarSherlock-4.2.0\ABSlibrary\bin\abslibrary.jar] (Unexpected end of ZLIB input stream) 
... 
Caused by: java.io.EOFException: Unexpected end of ZLIB input stream 
    at java.util.zip.InflaterInputStream.fill(InflaterInputStream.java:223) 
    ... 

您应检查以下内容:

  • 本在指定的位置文件abslibrary.jar
  • 它是一个有效的jar(你可以用一些解压缩工具打开它)吗?
  • 它是在编译过程中写入的吗?如果以某种方式异步写入,ProGuard读取它时可能仍然不完整。
+0

其实我第一次得到上述错误。当我第二次尝试导出时,它正常导出,并继续进行签名过程。在完成签名过程后,我试图在设备上测试应用程序,应用程序在启动时立即崩溃。这是崩溃logcat消息http://pastebin.com/TWbjsNp3 – 2013-02-11 06:03:26

+0

@suresh这是一个不同的问题。 SILENT字段通过反射访问。您应该使用-keep选项来保存它。请参阅ProGuard手册。 – 2013-02-14 09:38:33

+0

如果我的Android应用程序在ProGuard进程中引用另一个Android库项目,我会得到相同的错误。 – Alanmars 2014-04-17 06:22:54

我通过关于无法找到的jar的注解-libraryjars来解决这个问题。文件说不会出现jar,它会在运行时加载jar。