我构建了我的应用程序的发布版本,然后决定使用 ProGuard。我将以下内容添加到我的 project.properties 文件中:
proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt
当我尝试构建发布版本时,出现以下错误:
[2012-11-28 17:47:37 - MyApp] Proguard returned with error code 1. See console
[2012-11-28 17:47:37 - MyApp] Warning: oauth.signpost.signature.OAuthMessageSigner: can't find referenced class org.apache.commons.codec.binary.Base64
[2012-11-28 17:47:37 - MyApp] Warning: oauth.signpost.signature.OAuthMessageSigner: can't find referenced class org.apache.commons.codec.binary.Base64
[2012-11-28 17:47:37 - MyApp] Warning: oauth.signpost.signature.OAuthMessageSigner: can't find referenced class org.apache.commons.codec.binary.Base64
[2012-11-28 17:47:37 - MyApp] Warning: oauth.signpost.signature.OAuthMessageSigner: can't find referenced class org.apache.commons.codec.binary.Base64
[2012-11-28 17:47:37 - MyApp] Warning: oauth.signpost.signature.OAuthMessageSigner: can't find referenced class org.apache.commons.codec.binary.Base64
[2012-11-28 17:47:37 - MyApp] Warning: there were 5 unresolved references to classes or interfaces.
[2012-11-28 17:47:37 - MyApp] You may need to specify additional library jars (using '-libraryjars').
[2012-11-28 17:47:37 - MyApp] java.io.IOException: Please correct the above warnings first.
[2012-11-28 17:47:37 - MyApp] at proguard.Initializer.execute(Initializer.java:321)
[2012-11-28 17:47:37 - MyApp] at proguard.ProGuard.initialize(ProGuard.java:211)
[2012-11-28 17:47:37 - MyApp] at proguard.ProGuard.execute(ProGuard.java:86)
[2012-11-28 17:47:37 - MyApp] at proguard.ProGuard.main(ProGuard.java:492)
这显然是在引用我正在使用的路标库。我相信我已经正确添加了所需的罐子和库,但我猜不是?
我通过“添加外部 JAR...”按钮添加了路标 jar,并通过“添加外部类文件夹...”按钮添加了 commons-codec 库。
我在这里做错了什么?
更新:
我在项目的根目录中添加了一个名为 proguard-project.txt 的文件。
proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt
在 proguard-project.txt 文件中,我添加了以下内容:
-keep class org.apache.** { *; }
-keep class oauth.signpost.** { *; }
我仍然收到相同的错误。