gson proguard issue
See original GitHub issue✍️ Describe the bug
After the code is obfuscated, click Details to return an error
💣 Steps to reproduce
if isMinifyEnabled = true, we can see this issue.
🔧 Expected behavior
add gson proguard
📷 Screenshots
📱 Tech info
- Device: HUAWEI P30
- OS: HarmonyOS(Compatible with API 29)
- Chucker version: 3.5.2
📄 Additional context
if add gson proguard?
##---------------Begin: proguard configuration for Gson ----------
# 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.
-keepattributes Signature
# For using GSON @Expose annotation
-keepattributes *Annotation*
# Gson specific classes
-dontwarn sun.misc.**
#-keep class com.google.gson.stream.** { *; }
# Application classes that will be serialized/deserialized over Gson
-keep class com.google.gson.examples.android.model.** { <fields>; }
# Prevent proguard from stripping interface information from TypeAdapter, TypeAdapterFactory,
# JsonSerializer, JsonDeserializer instances (so they can be used in @JsonAdapter)
-keep class * extends com.google.gson.TypeAdapter
-keep class * implements com.google.gson.TypeAdapterFactory
-keep class * implements com.google.gson.JsonSerializer
-keep class * implements com.google.gson.JsonDeserializer
# Prevent R8 from leaving Data object members always null
-keepclassmembers,allowobfuscation class * {
@com.google.gson.annotations.SerializedName <fields>;
}
# 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
##---------------End: proguard configuration for Gson ----------
Issue Analytics
- State:
- Created 2 years ago
- Comments:8 (4 by maintainers)
Top Results From Across the Web
Proguard issue while using GSON - Stack Overflow
Proguard # removes such information by default, so configure it to keep all of it. -keepattributes Signature # Gson specific classes -keep class...
Read more >gson/proguard.cfg at master - GitHub
A Java serialization/deserialization library to convert Java Objects into JSON and back - gson/proguard.cfg at master · google/gson.
Read more >Mysterious null crash with Gson SerializedName fields when ...
But when you enable minifyEnabled to true in app gradle and run the app, it will crash with NullPointerException when GSON tries to...
Read more >Gson ProGuard rules
Gson ProGuard rules ... Gson - Java library that can be used to convert Java Objects into their JSON representation. It can also...
Read more >What if I use GSON serialization - ProGuard Rule Library
GSON uses reflection to determine the names of the attributes in the serialized JSON representation of your objects. If you obfuscate the ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@cortinico @vbuberen I’m sorry that I didn’t write back to you in time. I need to enable R8 to cover part of the test version.For the time being, this is our only log collection channel 😂. i will add proguard in my app.
Regardless of whether it is a bug or not, it should be shipped with Gson (or as a separate library if someone is willing to maintain it). It improves the whole ecosystem, which benefits all libraries and apps.