I try to get data from server with android, i work well when is set minifyEnabled false but when i set minifyEnabled true i can not revice data, it all is null
My version java is 17, My retrosit version is
com.squareup.retrofit2:retrofit:2.6.0
com.squareup.retrofit2:converter-gson:2.5.0
com.squareup.okhttp3:logging-interceptor:3.12.0
I try some other answer on stackoverflow
-keepclassmembers,allowobfuscation class * {
@com.google.gson.annotations.SerializedName <fields>;
}
-dontwarn retrofit2.**
-dontwarn org.codehaus.mojo.**
-keep class retrofit2.** { *; }
-keepattributes Signature
-keepattributes Exceptions
-keepattributes *Annotation*
-keepattributes RuntimeVisibleAnnotations
-keepattributes RuntimeInvisibleAnnotations
-keepattributes RuntimeVisibleParameterAnnotations
-keepattributes RuntimeInvisibleParameterAnnotations
-keepattributes EnclosingMethod
-keepclasseswithmembers class * {
@retrofit2.* <methods>;
}
-keepclasseswithmembers interface * {
@retrofit2.* <methods>;
}
My code to call api
interface ApiService {
@POST("/ipay-decode/")
suspend fun handleDataTest(
@Body requestBody: BaseRequest,
): BaseResponse
}
data class BaseRequest(
@SerializedName("encrypted")
val encrypted: String
)
open class BaseResponse {
@SerializedName("message")
var message: String = ""
}
Can anyone help me with any solution?
This is due to your models getting obfuscated when minify is enabled. To fix add the path to your models package to your Proguard rules.
Something like this should work: