Home » Android » android – Retrofit 2 returns null in release APK when minifyenable but ok in debug APK

android – Retrofit 2 returns null in release APK when minifyenable but ok in debug APK

Posted by: admin May 14, 2020 Leave a comment

Questions:

Getting null response but code 200 with Release APK when minify enable, when minify false then its ok.

enter image description here

But Getting expected response with debug APK when minify enable.

How to&Answers:

Problem solved 🙂

No issue with proguard-rules no need to add anything extra.

Needed to add SerializedName annotation if minifyEnabled even if variable name same as key.

That was the only Model which i had created manually 😛

Which works fine in Debug but not after Signed in. 🙂

Answer:

I had the same problem and my solution was to modify the ‘protection rules’ to exclude your class from obfuscation.

-keep public class com.your.packages.model.** {*;}

Answer:

You need to setup proguard-rule for release. If you want to test real server, you can create new build type, which targets server API

Cheers 🙂