2012-03-05 117 views
11

首先,對不起,如果這個話題已回答了,但我還沒有找到它......Proguard的Android和谷歌API客戶端

我是新與Android和Proguard的。在開發我的應用程序時,我想用proguard來縮小它的大小,當然。正如我在我的應用程序中使用一些來自google api客戶端的庫,我已經將它們添加爲外部罐子。

那麼,我的應用程序工作正常,沒有通過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 

和更多類似。

我按照谷歌開發者recomendations,並添加此行我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 

但它仍然出現這些警告消息。當我嘗試使用'-twtwarn'選項時,我的應用程序崩潰。

我已經閱讀了這些問題,更多:

誰能幫助?

+1

對不起,我發現它:缺少'jsr305-1.3.9'jar文件(我以前沒有意識到)。感謝所有。 – emiquelgavalda 2012-03-06 12:21:29

回答

16

嗨,我知道這已經通過將jsr305 jar文件添加到您的項目中解決了。然而,我花了一段時間才弄清楚在哪裏可以找到這個罐子以及如何處理它。

您可以在here獲得最新版本的這瓶下載最新的罐子,把它放在你的libs文件夾,然後它在Eclipse中添加到您的構建路徑,一切都應該就到了。

這也解決了我所有的問題。

+11

對於Gradle用戶,只需在build.gradle依賴項中添加'compile'c​​om.google.code.findbugs:jsr305:2.0.2''即可。 – Jonik 2014-01-05 15:14:18

相關問題