【问题标题】:Proguard with Android and Google API Client使用 Android 和 Google API 客户端进行 Proguard
【发布时间】:2012-03-05 10:38:34
【问题描述】:

首先,对不起,如果这个话题已经回答了,但我没有找到它......

我是 Android 和 Proguard 的新手。在我的应用程序开发结束时,我当然想使用 proguard 来减小它的大小。由于我在我的应用程序中使用来自 google 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”选项时,我的应用程序崩溃了。

我已经阅读了这些问题以及更多内容:

谁能帮忙?

【问题讨论】:

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

标签: android proguard google-api-java-client


【解决方案1】:

您好,我知道这已经通过将jsr305 jar 文件添加到您的项目中来解决。然而,我花了一段时间才弄清楚在哪里可以找到这个罐子以及如何处理它。

你可以在here获得这个jar的最新版本下载最新的jar并将它放在你的libs文件夹中,然后将它添加到你在Eclipse中的构建路径中,一切都应该是去吧。

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

【讨论】:

  • 对于 Gradle 用户,只需在 build.gradle 依赖项中添加 compile 'com.google.code.findbugs:jsr305:2.0.2'
猜你喜欢
  • 2013-11-05
  • 1970-01-01
  • 2017-05-16
  • 1970-01-01
  • 2016-02-26
  • 1970-01-01
  • 2019-05-26
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多