简体   繁体   中英

Due to Proguard I am getting this error for list iterator

That is my stack trace, When I am running my app in debug it runs perfectly fine but when I am running my app in release mode it gives below error when I click on list item.

java.lang.NullPointerException: Attempt to invoke interface method 'java.util.Iterator java.util.List.iterator()' on a null object reference at dkw.a(Unknown Source) at dmh.a(Unknown Source) at dmh.success(Unknown Source) at retrofit.CallbackRunnable$1.run(Unknown Source) at android.os.Handler.handleCallback(Handler.java:739) at android.os.Handler.dispatchMessage(Handler.java:95) at android.os.Looper.loop(Looper.java:135) at android.app.ActivityThread.main(ActivityThread.java:5930) at java.lang.reflect.Method.invoke(Native Method) at java.lang.reflect.Method.invoke(Method.java:372) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1405) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1200)

I can assume that the list is empty due to GSON not deserialising the JSON properly since your POJO got obfuscated.

In your class that contains the list you're trying to iterate on annotate your variables with @SerializedName("json_variable_name_here") So for example if JSON is:

{
"name":"alice"
"foo" : "bar",
    }

Your POJO should look like:

@SerializedName("name")
String name;

@SerializedName("foo")
String foo;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM