From ac6e590953f558c0ea247b0e3bc077c9bd4f1e23 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B8ren=20Gjesse?= Date: Tue, 15 Aug 2023 10:53:35 +0200 Subject: [PATCH] Addressed review comments --- gson/src/main/resources/META-INF/proguard/gson.pro | 10 +++++++--- shrinker-test/common.pro | 2 ++ shrinker-test/proguard.pro | 6 ------ 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/gson/src/main/resources/META-INF/proguard/gson.pro b/gson/src/main/resources/META-INF/proguard/gson.pro index e5aa2f1515..f9eb83e849 100644 --- a/gson/src/main/resources/META-INF/proguard/gson.pro +++ b/gson/src/main/resources/META-INF/proguard/gson.pro @@ -22,6 +22,7 @@ # Keep class TypeToken (respectively its generic signature) if present -if class com.google.gson.reflect.TypeToken -keep,allowobfuscation class com.google.gson.reflect.TypeToken +#-keep class com.google.gson.reflect.TypeToken { *; } # Keep any (anonymous) classes extending TypeToken -keep,allowobfuscation class * extends com.google.gson.reflect.TypeToken @@ -54,9 +55,12 @@ (); } -# Keep fields annotated with @SerializedName for classes which are present. +# Keep fields annotated with @SerializedName for classes which are referenced. # If classes with fields annotated with @SerializedName have a no-args -# constructor keep that as well. +# constructor keep that as well. Based on +# https://issuetracker.google.com/issues/150189783#comment11. +# See also https://github.com/google/gson/pull/2420#discussion_r1241813541 +# for a more detailed explanation. -if class * -keepclasseswithmembers,allowobfuscation class <1> { @com.google.gson.annotations.SerializedName ; @@ -64,6 +68,6 @@ -if class * { @com.google.gson.annotations.SerializedName ; } --keepclassmembers,allowobfuscation class <1> { +-keepclassmembers,allowobfuscation,allowoptimization class <1> { (); } diff --git a/shrinker-test/common.pro b/shrinker-test/common.pro index ab45d2039a..ec34c2eef9 100644 --- a/shrinker-test/common.pro +++ b/shrinker-test/common.pro @@ -38,3 +38,5 @@ -keepclassmembernames class com.example.ClassWithVersionAnnotations { ; } + +-dontobfuscate diff --git a/shrinker-test/proguard.pro b/shrinker-test/proguard.pro index 987f4d377d..c80942c121 100644 --- a/shrinker-test/proguard.pro +++ b/shrinker-test/proguard.pro @@ -12,9 +12,3 @@ -keepclassmembernames class com.example.NoSerializedNameMain$TestClassNotAbstract { ; } --keepclassmembernames class com.example.NoSerializedNameMain$TestClassWithoutDefaultConstructor { - ; -} -#-keep class com.example.ClassWithSerializedName { -# (...); -#}