Android, Google Drive SDK and Proguard

(This is old and out of date, but it might help…)


Having managed to get Finance backing up it’s data to Google Drive, we were bemused to see that the released version of the application stored the files with no-name.

We knew it was probably a Proguard problem, but tracking it down was an exercise in frustration.

Problem Solving

We could tell that the data we associated with the file was being lost and suspected that Proguard was stripping out the data. Worryingly, there were no errors reported by the application. As far as it was concerned, all was working well. Unfortunately, this makes finding the problem very difficult.

One of the first starting points was to turn off all the Proguard optimisations and try to see which one breaks the code.


It worked fine with these settings, so we knew it was definitely a Proguard problem. Selectively turning these on and off highlighted the problem as being in the obfuscation step.

Debugging Joy

Debugging an obfuscated application is fairly pointless, as everything has been munged by the obfuscation process. We had to fall back to adding debug statements in a random fashion through the Google Drive backup code.

As luck would have it, we noticed one of our debug statements indicated that the Files object had some obfuscated fields that were probably causing a problem. A quick look at the class file showed that this class had some annotations and we’d seen references in Proguard to keep annotations. Aha, we thought and added the following line to our Proguard file:

-keepattributes *Annotation*,Signature

Nope, didn’t improve things.

OK, so how about we keep all the fields for these GSON objects?

-keep class * extends {
** ;

Now, we’re making progress. Our debug statements correctly show the fields.

But it still doesn’t work.


What followed was 1/2 day of frustration as we tried all sorts of combinations of Proguard settings and -keep options. Each thing we tried either had no effect or introduced some strange responses from the Google Drive server. HTTP 403 and HTTP 404 errors were common.

Eventually we found a combination that worked. It’s a very broad Proguard setting but by this time we’d had enough.

-dontwarn sun.misc.Unsafe

-keepattributes *Annotation*,Signature

-keep class * extends {

-keep class** {


To read up on the Finance application, start here.


2 thoughts on “Android, Google Drive SDK and Proguard

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s