question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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:closed
  • Created 2 years ago
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
li-lancecommented, Jan 5, 2022

@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.

1reaction
MiSikoracommented, Dec 29, 2021

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found