[![Proguard rules][gson parsing version 2.8.0]][android official volley version 1.0.0]
Gson parsing is not working when ProGuard rules enabled. i have used official version of Volley 1.0.0 and Gson version 2.8.0. So, whenever I enable ProGuard rules, Gson parsing is not working. I have also added required rules in proguard-rules.pro
file still it is not working.
Dependency
compile 'com.google.code.gson:gson:2.8.0'
compile 'com.android.volley:volley:1.0.0'
ProGuard rules:
-ignorewarnings
-keep class org.joda.** { *; }
-dontwarn org.joda.convert.FromString
-dontwarn org.joda.convert.ToString
-dontwarn org.joda.convert.**
-dontwarn org.joda.time.**
-keep class org.joda.time.** { *; }
-keep interface org.joda.time.** { *; }
-dontwarn org.mockito.**
-dontwarn sun.reflect.**
-dontwarn android.test.**
-dontwarn java.lang.management.**
-keepattributes Signature
-keep class com.google.gson.examples.android.model.** { *; }
-keep class com.google.gson.**{ *; }
-dontwarn com.fasterxml.jackson.**
-keep class com.fasterxml.jackson.** { *; }
Parsing method
private static void verifyResponse(final String response, final RequestCode requestCode, final IListener listener) throws IOException, ClassNotFoundException {
if (listener != null) {
ResponseStatus responseStatus;
try {
JSONObject jResult = new JSONObject(response);
if (jResult.has("d")) {
String strResult = jResult.getString("d");
jResult = new JSONObject(strResult);
Debug.trace("ResponseStatusA " + jResult.toString());
}
responseStatus = gson.fromJson(new JSONObject(jResult.toString()).toString(), ResponseStatus.class);
Debug.trace("ResponseStatusB " + responseStatus.getStatus());
processSuccess(jResult.toString(), responseStatus, requestCode, listener);
/* if (responseStatus.isFail()) {
processError(responseStatus, listener);
} else {
if (responseStatus.isSuccess()) {
listener.onHideProgressDialog();
processSuccess(jResult.toString(), responseStatus, requestCode, listener);
}
}*/
} catch (JsonSyntaxException | JSONException e) {
e.printStackTrace();
}
}
}