I use retrofit in application for calling http requests and use gson for parsing json objects. I get response correctly in debug mode, but in build with release mode my response is null and my app doesn't work any more
I found the answer after a while ... I use proguard for release mode so because of Obfuscation the model fields names changes so gson cant parse the http response, the best way for preventing this problem is using @SerializedName("field_name") annotation in fields to could be parsed after Obfuscation.
Probably you have proguard enabled for release mode. Check your app gradle build and see if minify is enabled. If you disable it your code won’t get obfuscate and you will no longer have any issues with release build.
If you do want to obfuscate your code which is good for security of your app then you have to find proguard rules for every library you have included in your app. Then you have to add those rules in your proguard rules file. Also you have to skip POJO classes from getting obfuscate.
Common proguard rules for most of the libraries can be found in this file created by @jemshit
https://gist.github.com/jemshit/767ab25a9670eb0083bafa65f8d786bb
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