1.without proguard Everything working fine. while enabling the Proguard, all the header and body models are getting obfuscated.
2.Retrofit2 not able to pass data with model objects.
D/OkHttp: Content-Type: application/json
Content-Length: 80
{"a":{"a":"123","b":"***","c":"","d":"Data","f":"1.0"},"b":{"a":""}}
--> END POST (80-byte body)
below mentioned Proguard rules are already added in my code still getting same problem, kindly help me to fix this issue.
# Retrofit
-dontwarn retrofit2.**
-dontwarn org.codehaus.mojo.**
-keep class retrofit2.** { *; }
-keepattributes Signature
-keepattributes Exceptions
-keepattributes *Annotation*
-keepattributes RuntimeVisibleAnnotations
-keepattributes RuntimeInvisibleAnnotations
-keepattributes RuntimeVisibleParameterAnnotations
-keepattributes RuntimeInvisibleParameterAnnotations
-keepattributes EnclosingMethod
-keepclasseswithmembers class * {
@retrofit2.* <methods>;
}
-keepclasseswithmembers interface * {
@retrofit2.* <methods>;
}
# Platform calls Class.forName on types which do not exist on Android to determine platform.
-dontnote retrofit2.Platform
# Platform used when running on RoboVM on iOS. Will not be used at runtime.
-dontnote retrofit2.Platform$IOS$MainThreadExecutor
# Platform used when running on Java 8 VMs. Will not be used at runtime.
-dontwarn retrofit2.Platform$Java8
# Retain generic type information for use by reflection by converters and adapters.
-keepattributes Signature
# Retain declared checked exceptions for use by a Proxy instance.
-keepattributes Exceptions
-keepclasseswithmembers class * {
@retrofit2.http.* <methods>;
}
-keepclassmembers class * {
*** get*();
void set*(***);
}
-keepattributes Signature
-dontwarn retrofit.**
-keep class retrofit.** { *; }
-keepattributes Signature
-keepattributes Exceptions
-keep class sun.misc.Unsafe { *; }
-keep class com.google.gson.stream.** { *; }
Update: My Request header and data
RequestPojo requestPojo = null;
try {
requestPojo = new RequestPojo();
RequestHeader requestHeader = new RequestHeader();
requestHeader.setID("123");
requestHeader.setNo("*******");
requestHeader.setName("XYZ");
requestHeader.setCode("ABC");
requestHeader.setAge("1");
/*Request DATA*/
RequestData requestData = new RequestData();
requestData.setData("Hai");
requestPojo.requestHeader = requestHeader;
requestPojo.requestData = requestData;
} catch (Exception e) {
e.printStackTrace();
}