Google Drive API doesn't play well with ProGuard (NPE) Google Drive API doesn't play well with ProGuard (NPE) android android

Google Drive API doesn't play well with ProGuard (NPE)


A combination of the following has worked for me:

-keep class com.google.** { *;}-keep interface com.google.** { *;}-dontwarn com.google.**-dontwarn sun.misc.Unsafe-dontwarn com.google.common.collect.MinMaxPriorityQueue-keepattributes *Annotation*,Signature-keep class * extends com.google.api.client.json.GenericJson {*;}-keep class com.google.api.services.drive.** {*;}

This provided a working proguard compatible solution for a recent Google Drive project.

Cannot take all credit for this solution though, originally found at this link here


Proper combination is :

-keepattributes Signature,RuntimeVisibleAnnotations,AnnotationDefault

There's proguard configuration prepared by Google for project google-api-java-client

https://github.com/google/google-api-java-client/blob/57fe35766cbba0a0d5a9a296be81468d730a29f8/google-api-client-assembly/proguard-google-api-client.txt


First -keeping a class does not mean to not touch it. It means do not change its name, and use it as a basis for determining if other classes are not referenced & can be deleted.

Optimization still occurs, which is likely your problem. Next step I would do is try with:-dontoptimize

This should cause your other optimizations to be ignored.

BTW, not sure what version of SDK you are using. Am using 15, 20 is latest, and a proguard-project.txt file is create with the project. The optimization options it uses is:

-optimizations !code/simplification/arithmetic,!code/simplification/cast,!field/*,!class/merging/*

If turning off optimization gets it running, maybe turning off all the optimizations (that's what ! does) the SDK does, will allow you to do optimization as well.