Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Proguard with Android and Google API Client

first of all, sorry if this topic has been answered, but I have not found it...

I'm new with Android and Proguard. At the ending of developing my appication, I want to reduce its size using proguard, of course. As I am using some libraries from google api client in my application, I've added them as external jars.

Well, my app is working ok without passing proguard step, but when I try to export it, it begins my headache. A lot of warnings that I don't know how skip or arrange. Something as this:

[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

and more similar.

I have followed the Google developers recomendations, and added this lines to my 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

but it continues appearing all these warning messages. And when I tried to use '-dontwarn' option, my app crashes.

I have read these questions, and more:

  • Proguard and Android :(
  • Android & Proguard?

Can anyone help?

like image 776
emiquelgavalda Avatar asked Mar 05 '12 10:03

emiquelgavalda


1 Answers

Hi I know that this was already solved by adding in the jsr305 jar file to your project. However it took me a while to work out where I could find this jar and what to do with it.

You can get the latest version of this jar at here Download the latest jar and put it in your libs folder, then add it to your build path in Eclipse and everything should be right to go.

This fixed all of my problems as well.

like image 198
Cassie Avatar answered Sep 21 '22 13:09

Cassie