添加了ProGuard,现在我无法构建发布版本

时间:2012-11-28 23:52:07

标签: android

我构建了我的应用程序的发布版本,然后决定我想使用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)

这显然是引用我正在使用的路标库。我相信我已正确添加了所需的罐子和库,但我猜不是吗?

enter image description here

我通过“Add External JARs ...”按钮添加了路标罐,并通过“Add External Class Folder ...”按钮添加了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.** { *; }

我仍然收到同样的错误。

2 个答案:

答案 0 :(得分:1)

我不知道解释,但我对番石榴库有同样的问题,有完全相同的警告信息。我通过这样做来修复它:

-dontwarn com.google.common.collect.MinMaxPriorityQueue

还有AdMob课程。一样。所以,也许你也可以这样做:

-dontwarn org.apache.commons.codec.binary.Base64

因为您已经在代码中成功使用了这些类。

警告:由于我不确切知道这是做什么的,所以请谨慎行事并尝试阅读。

答案 1 :(得分:0)

可能需要告诉proguard不要弄乱你的proguard.cfg中的那些类

-keep class org.apache.** { *; }
-keep class oauth.signpost.** { *; }