ProGuard for Android and Retrofit2 Converter Gson? -


i using proguard in project giving wrong data in new gson().tojson(request);

i getting out put

{"a":"manage","b":"689184d4418b6d975d9a8e53105d3382","c":"10","d":"76"} 

instead of

{"username":"manage","password":"689184d4418b6d975d9a8e53105d3382","value":"10","store":"76"} 

my proguard rule

-dontwarn okio.** -dontwarn retrofit2.platform$java8 -dontwarn sun.misc.unsafe -dontwarn org.w3c.dom.bootstrap.domimplementationregistry -dontwarn retrofit2.** -keep class retrofit2.** { *; } -keepattributes signature -keepattributes exceptions -keepclassmembers class rx.internal.util.unsafe.** {     long producerindex;     long consumerindex; }  -keepclasseswithmembers class * {     @retrofit2.http.* <methods>; } -keep class com.google.gson.** { *; } -keep class com.google.inject.** { *; } 

and using

 compile 'com.squareup.retrofit2:converter-gson:2.0.0' 

is there new recommended proguard configuration retrofit2:converter-gson in android?

you either want keep class using gson or use @serializedname annotation.

option 1 (keep class)

 // classes in package -keep class com.example.app.json.** { *; } // or specific class -keep class com.example.app.json.specificclass { *; } 

option 2 (use @serializedname):

 public class yourjsonclass{    @serializedname("name") string username;     public myclass(string username) {      this.username = username;    }  } 

with second option proguard still obfuscates class , field names gosn can use annotation correct name each field


Comments

Popular posts from this blog

magento2 - Magento 2 admin grid add filter to collection -

Android volley - avoid multiple requests of the same kind to the server? -

Combining PHP Registration and Login into one class with multiple functions in one PHP file -