Android ProGuard issues with Google API libraries

This will be a short post. So, I have working with the Google API java library for Android and time has come to package the app for release and boom! ProGuard problems! First I had an issue with MinMaxPriorityQueue. When I tried to “Export Signed Application Package”, ProGuard would fail with a warning about this class. To get past this, you need to tell ProGuard not to warn you about it. Add this to your proguard.cfg:


Next, I had a problem with the JSON response from the API. It would complain about how there isn’t a publicly available constructor in a package (ex: or something like that). Your error may not be the same but it is more or less the same problem as mine (or anyone else using Google API libraries for Android). So you need to tell ProGuard to keep certain API classes from obfuscation:

-keep class<full package name of whatever library you are using>

I suggest also adding any other package (or individual classes) that you have declared in your application that is designated as a model for API responses. One last thing to note is, if your ProGuard config file doesn’t already have it, you should also add this:

-keepclassmembers class * { <fields>;

This would have already been added for you if you used the “android update project -p <your project>” in your command line (or Terminal) or if you have been using the latest Android tools.