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
How to configure proguard for Android application using Google Drive SDK?
Use the following in your proguard-google-api-client.txt
to preserve the required attributes and class members.
-keepattributes Signature,RuntimeVisibleAnnotations,AnnotationDefault
-keepclassmembers class * {
@com.google.api.client.util.Key <fields>;
}
-keep class com.google.** { *;}
-keep interface com.google.** { *;}
-dontwarn com.google.**
# Needed by google-http-client-android when linking against an older platform version
-dontwarn com.google.api.client.extensions.android.**
# Needed by google-api-client-android when linking against an older platform version
-dontwarn com.google.api.client.googleapis.extensions.android.**
Android App crashes after proguard obfuscation (Google plus people search)
Can you try:
-keep class com.google.api.services.plus.** { *; }
You can also check what gets taken away by looking at the proguard output files.
EDIT - Your problem might be similar to these:
- http://softwyer.wordpress.com/2012/10/20/android-google-drive-sdk-and-proguard/
- Google Drive API doesn't play well with ProGuard (NPE)
These are for Drive, but the location of the NPE is similar, and they provide a working proguard config you can start with.
ProGuard meets Drive API
I just found the reason why it failed.
Not proguard is the issue. I genereated a SHA-Hash and entered it in the Google API Console for my app. The release version is signed with another keystore and I had to generate another SHA-Hash for this version.
Android: Integration with google drive sdk doesn't work in obfuscated build?
This was fixed by adding the below to my proguard config, found in the following link. Given the error message, it was surprising this was an obfuscation issue.
-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.** {
*;
}
Google Drive API doesn't play well with ProGuard (NPE)
Google Drive API fails because library's google.drive function doesn't exist
If you are using googleapis of latest version (googleapis@26.0.1), the script of Quickstart has to be modified. Please modify as follows. For node.js, this is confirmed at not only Drive API but also other APIs. I think that the document is not keep up with the updated library.
From :
var google = require('googleapis');
To :
var {google} = require('googleapis');
Note :
- When you use googleapis with v24 or less,
var google = require('googleapis');
can be used.
Reference :
- https://github.com/google/google-api-nodejs-client/releases/tag/v26.0.0
If this was not useful for your situation, I'm sorry.
Files.List is empty but only when signed with release certificate
As per earlier comment:
Any chance Proguard kicks in when exporting your signed APK? If you rely on i.e. variable names to map the JSON onto POJOs, this is likely to brake without the appropriate Proguard exclusions/rules. Have a look in your project.properties
file and comment out any lines in the form of proguard.config=<file_name>
. After that, export another signed APK and retest.
Related Topics
How to Make Layouts for Several Android Screen Sizes
How to Detect When the User Launches Another App? (Android)
Firebase: How to Set Default Notification Channel in Android App
How to Set an Imageview's Image from a String
Pop the Fragment Backstack Without Playing the Pop-Animation
Android Webview Anchor Link (Jump Link) Not Working
Firebase Dynamic Link Not Opening the App
Android Audiotrack Playing .Wav File, Getting Only White Noise
How to Create a New Avd in Eclipse
Deep Linking Not Working in Chrome
Speech to Text from Own Sound File
How to Detect Wifi Tethering State
Floatingactionbutton Doesn't Hide
Resizing Imageview to Fit to Aspect Ratio
Android Studio 4.1 Plugin Error: Plugin * Is Incompatible (Supported Only in Intellij Idea)