问题 使用Android和Google API客户端的Proguard


首先,对不起,如果这个话题已被回答,但我还没找到...

我是Android和Proguard的新手。在开发我的应用程序结束时,我想用proguard减小它的大小,当然。由于我在我的应用程序中使用谷歌api客户端的一些库,我已将它们添加为外部jar。

好吧,我的应用程序工作正常,没有通过proguard步骤,但当我尝试导出它,它开始我的头痛。很多警告,我不知道如何跳过或安排。这样的东西:

[2012-03-05 07:20:06 - CollaJoveThreads] Proguard returned with error code 1. See console
[2012-03-05 07:20:06 - CollaJoveThreads] Warning: com.google.common.base.Equivalence: can't find referenced class javax.annotation.Nullable
[2012-03-05 07:20:06 - CollaJoveThreads] Warning: com.google.common.base.Equivalence: can't find referenced class javax.annotation.Nullable
[2012-03-05 07:20:06 - CollaJoveThreads] Warning: com.google.common.base.Equivalence: can't find referenced class javax.annotation.Nullable
[2012-03-05 07:20:06 - CollaJoveThreads] Warning: com.google.common.base.Equivalences$Impl$1: can't find referenced class javax.annotation.Nullable
[2012-03-05 07:20:06 - CollaJoveThreads] Warning: com.google.common.base.Equivalences$Impl$1: can't find referenced class javax.annotation.Nullable

和更相似的。

我跟踪了Google开发人员的推荐,并将这些行添加到我的proguard.cfg中:

# Needed by google-api-client to keep generic types and @Key annotations accessed via reflection
-keepclassmembers class * {
  @com.google.api.client.util.Key <fields>;
}

-keepattributes Signature,RuntimeVisibleAnnotations,AnnotationDefault,*Annotation*

-dontwarn sun.misc.Unsafe

但它继续出现所有这些警告信息。当我尝试使用'-dontwarn'选项时,我的应用程序崩溃了。

我已经阅读了这些问题,还有更多:

有人可以帮忙吗?


4312
2018-03-05 10:38


起源

对不起,我发现它:它缺少'jsr305-1.3.9'jar文件(我之前没有意识到)。谢谢大家。 - emiquelgavalda


答案:


嗨,我知道这已经通过添加来解决了 jsr305 jar文件到你的项目。然而,我花了一段时间才找到可以找到这个罐子的地方以及如何处理它。

你可以在这里获得这个罐子的最新版本 这里 下载最新的jar并将其放入你的 libs 文件夹,然后将其添加到您的 建立路径 在Eclipse中,一切都应该是正确的。

这也解决了我所有的问题。


16
2018-06-20 07:00



对于Gradle用户,只需添加即可 compile 'com.google.code.findbugs:jsr305:2.0.2' 在build.gradle依赖项中。 - Jonik