Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

After set minifyEnabled true in debug mode api call not working properly

After minifyEnabled true in build.gradle

Like below

 buildTypes {
    release {
        debuggable false
        minifyEnabled true
        shrinkResources true
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'

    }
    debug {
        debuggable true
        minifyEnabled true
        shrinkResources true
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}

When i make api call while minifyEnabled true i got success but some Parameters value change which is different from expected value.

And

When i make api call while **minifyEnabled false ** i got actual value which comes from back-end side.

(i.e.) i got isValidUser parameter in api response which is boolean actual value is isValidUser=true which is expected but i got isValidUser=false.

help me what is the problem with my build.gradle file?

like image 626
Arbaz.in Avatar asked Dec 07 '25 14:12

Arbaz.in


2 Answers

Please specify exactly what part is not working, but generally its from the models, so exclude them in the rules file as:

# Models
-keepclassmembers class com.example.models.** {*;}

# GSON
-keepattributes Signature
-keepattributes *Annotation*
-dontwarn sun.misc.**
-keep class com.google.gson.examples.android.model.** { *; }
-keep class * implements com.google.gson.TypeAdapterFactory
-keep class * implements com.google.gson.JsonSerializer
-keep class * implements com.google.gson.JsonDeserializer
like image 153
Farouq Afghani Avatar answered Dec 09 '25 20:12

Farouq Afghani


with the help of Payam Kokabi, issue is solved minifyEnabled true is will not change the value when we declare -keep class YOUR CLASS ** { *; } in your proguard-rules.pro file.

like image 37
Arbaz.in Avatar answered Dec 09 '25 19:12

Arbaz.in



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!