2

我希望我的应用程序受到 progaurd 保护。为此,我浏览了一些教程,帖子,最后从这篇帖子中我知道我应该只这样做:

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

在取消上述建议的行后,我尝试导出未签名的应用程序。但得到一个出口错误说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 或错过了步骤?

4

2 回答 2

1

堆栈跟踪中列出了根本原因:

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存在于给定位置?
  • 它是一个有效的罐子(你可以用一些解压工具打开它)吗?
  • 它是在构建过程中编写的吗?如果它以某种方式被异步写入,当 ProGuard 读取它时它可能仍然不完整。
于 2013-02-08T23:39:05.560 回答
0

我通过注释 -libraryjars 关于找不到的 jar 解决了这个问题。文档说不会存在 jar,它会在运行时加载 jar。

于 2015-08-11T06:53:29.393 回答