Skip to content Skip to sidebar Skip to footer

Null Response In Signed Apk - Proper Response In Debug Apk

I am using Retrofit for network calls. I am facing weird issue with signed APK. Retrofit request, @FormUrlEncoded @Headers('Accept: application/json') @POST('******') Call

Solution 1:

please set minify as false. (Build/Edit Buildtype) if you set this option when code release, some part is removed.

Solution 2:

In my case I removed tools:ignore="HardcodedDebugMode" in AndroidManifest.xml, which I added for debugging.

After made the above change, received proper response from Retrofit request in Signed APK.

Note: I know this is a late reply and I am posting it for someone facing similar problem in future.

Solution 3:

If you are building release apk then there will be proguard rule will be applied. Proguard will obfuscate you class file.

In your build.gradle(app)

 buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }

try to remove this rule

proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'

and re-build release apk.If it is working then it is issue with proguard rule.

Solution 4:

I added SerializedName annotation to all fields in my version of UserInfoResponse class as suggested in Retrofit 2 returns null in release APK when minifyenable but ok in debug APK. Still did not solve the problem.

Adding

-keep class UserInfoResponse { *; }

rule in proguard rules fixed it for me.

Solution 5:

The issue was with deserialization,

I solved it by following this,

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

Post a Comment for "Null Response In Signed Apk - Proper Response In Debug Apk"