1. без proguard Все работает нормально.при включении Proguard все модели заголовка и тела становятся запутанными.
2.Retrofit2 не может передавать данные с объектами модели.
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)
нижеупомянутые правила Proguard уже добавлены вМой код все еще сталкивается с той же проблемой, пожалуйста, помогите мне решить эту проблему.
# 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.** { *; }
Обновление: Заголовок моего запроса и данные
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();
}