2013-02-08 117 views
2

我希望我的應用程序受到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或錯過了步驟?

回答

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
  • 它是一個有效的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

0

我通過關於無法找到的jar的註解-libraryjars來解決這個問題。文件說不會出現jar,它會在運行時加載jar。

相關問題