diff --git a/docs/setup.md b/docs/setup.md index e0da06569..4a8b58b93 100644 --- a/docs/setup.md +++ b/docs/setup.md @@ -75,6 +75,30 @@ If you are using Gradle, add this to your dependencies: compile 'com.google.http-client:google-http-client:[VERSION]' ``` +## ProGuard + +The library uses reflection to access generic types and fields annotated with `@Key`. Add the +following rules to your ProGuard configuration: + +``` +-keepattributes Signature,RuntimeVisibleAnnotations,AnnotationDefault + +-keepclassmembers class * { + @com.google.api.client.util.Key ; +} + +-keepclasseswithmembers,allowobfuscation class * { + @com.google.api.client.util.Key ; + public (); +} +``` + +When using `google-http-client-android`, also add: + +``` +-dontwarn com.google.api.client.extensions.android.** +``` + ## Download the library with dependencies Download the latest assembly zip file from Maven Central and extract it on your computer. This zip @@ -85,4 +109,3 @@ the dependencies folder. For more details about the contents of the download, se - diff --git a/google-http-client-assembly/proguard-google-http-client.txt b/google-http-client-assembly/proguard-google-http-client.txt index 55dfdb09b..2cb641be7 100644 --- a/google-http-client-assembly/proguard-google-http-client.txt +++ b/google-http-client-assembly/proguard-google-http-client.txt @@ -10,6 +10,13 @@ @com.google.api.client.util.Key ; } +# Needed to keep public no-argument constructors used to instantiate data models via reflection + +-keepclasseswithmembers,allowobfuscation class * { + @com.google.api.client.util.Key ; + public (); +} + # Needed by google-http-client-android when linking against an older platform version -dontwarn com.google.api.client.extensions.android.**