proguard: Unable to disable obfuscation to one specific class

543 Views Asked by At

I have the following for debug purposes:

debug {
    minifyEnabled true
    shrinkResources true
    proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}

I have a class MyClass, and I'm using Gson to convert it to JSON before sending it to my server. While I expect the JSON to be {"name":"blah", "age": 40}, the server receives it as {"a":"blah", "b": 40}. I tried several things in the proguard rule files but to no avail. Here is an example of my latest try:

-keep public class com.package.package.MyClass { *; }

What am I missing? Thanks

1

There are 1 best solutions below

1
On

Have you tried serialization annotation

@SerializedName("name")
String name ="";