From 2f30a89fea3cf792496d71edd5d4ef36495cd037 Mon Sep 17 00:00:00 2001 From: Arnab Nandy Date: Sat, 18 Jul 2026 11:42:16 +0530 Subject: [PATCH 1/2] docs: restore ProGuard setup instructions Signed-off-by: Arnab Nandy --- docs/setup.md | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/docs/setup.md b/docs/setup.md index e0da06569..664a20cd8 100644 --- a/docs/setup.md +++ b/docs/setup.md @@ -75,6 +75,25 @@ 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 ; +} +``` + +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 +104,3 @@ the dependencies folder. For more details about the contents of the download, se - From e924cee1946d7652c5fe7a3d94d76ca19ff58d23 Mon Sep 17 00:00:00 2001 From: Arnab Nandy Date: Sat, 10 Oct 2026 08:20:51 +0530 Subject: [PATCH 2/2] fix: preserve model constructors with ProGuard Signed-off-by: Arnab Nandy --- docs/setup.md | 5 +++++ .../proguard-google-http-client.txt | 7 +++++++ 2 files changed, 12 insertions(+) diff --git a/docs/setup.md b/docs/setup.md index 664a20cd8..4a8b58b93 100644 --- a/docs/setup.md +++ b/docs/setup.md @@ -86,6 +86,11 @@ following rules to your ProGuard configuration: -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: 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.**