I'm using the Jackson JSON library within my Android app to parse JSON from a REST API. Everything works fine other than a couple of instances where I'm using ObjectMapper.readValue
and ObjectMapper.treeToValue
to deserialise the JSON to objects. It works fine every time when running the 'debug' build variant, but when running the 'release' build it fails to create the object and just returns null instead.
I've read a lot about ensuring that the Proguard settings are configured properly, but I'm not using Proguard and have removed all references to Proguard in my app. Is there anything else that might be causing the issue with the 'release' build?
Jonathan
Turns out the problem was due to the class I was using to deserialise my JSON was declared within my activity class, therefore an inner class. I read that inner classes can be used with the Jackson ObjectMapper as long as they were declared static which this was, so not exactly sure why it didn't work in 'release' mode. As soon as I moved it to become a regular public class it all worked fine.
This was the only post I found that described a similar situation I experienced but in my case there was no inner class. It turns out that it was due to the fact that some fields were package private. Everything worked fine in a debug build but on the release build those fields were null. Changed them to public and it worked fine. Setting getters/setters for all would probably also work but I didn't try it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With