Open nitinsethi86 opened 8 months ago
I tried the latest rules from Gson too. It didn't work.
Did you try the rules from https://github.com/google/gson/blob/main/gson/src/main/resources/META-INF/proguard/gson.pro? They will also be included automatically in the next Gson release.
A few questions:
ClassCastException
can also have different causes, see the Troubleshooting Guide, and maybe your AGP upgrade is now triggering this for some reason (?).
Gson version
2.8.6
Java / Android version
JDM 17 and All Android versions.
Used tools
Description
We recently moved from AGP 8.0.2 to AGP 8.2.2.
We use gson version 2.8.6 with below set of proguard rules:
GSON 2.2.4 specific rules
Gson uses generic type information stored in a class file when working with fields. Proguard
removes such information by default, so configure it to keep all of it.
For using GSON @Expose annotation
-keepattributes EnclosingMethod
Gson specific classes
-keep class sun.misc.Unsafe { *; } -keep class com.google.gson.stream.* { ; }
Prevent R8 from leaving Data object members always null
-keepclassmembers,allowobfuscation class * { @com.google.gson.annotations.SerializedName; }
Retain generic signatures of TypeToken and its subclasses with R8 version 3.0 and higher.
-keep,allowobfuscation,allowshrinking class com.google.gson.reflect.TypeToken -keep,allowobfuscation,allowshrinking class * extends com.google.gson.reflect.TypeToken
-if class * -keepclasseswithmembers class <1> {