I am using Retrofit in my app. Everything is working fine but when I create the release version of the app some calls aren't working.
What could the problem be? I already disabled minifyEnabled
in my gradle file.
Edit: Found the real problem: I get the user data by a specific API call. I map this on the following class:
String ID;
String user_login;
String user_nicename;
String user_email;
String display_name;
For some reason, all the fields are filled except for ID. When I don't use release but debug the ID field gets filled.
Try this:
-dontnote okhttp3.**, okio.**, retrofit2.**
-dontwarn retrofit2.**
-keep class retrofit2.** { *; }
If above code not work then add @Keep
annotation to your model class like this.
import androidx.annotation.Keep;
@Keep
public class Blog {
private String id;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
}
make sure have provided specific rules for retrofit.
If you've enabled minifyEnabled=true
then
add below rules for retrofit in your proguard-rules.pro
file
-dontnote okhttp3.**, okio.**, retrofit2.**
-dontwarn retrofit2.**
-keep class retrofit2.** { *; }
For me, I was trying to fetch data using retrofit. My model was like following:
data class ChecksumResponseEntity(
@SerializedName("code")
val code: Double,
@SerializedName("message")
val message: String,
@SerializedName("checksum")
val checksum: String
)
The issue was that all values were being initialized to null instead of what was coming in response.
A added following in proguard file but it did not help me:
-dontnote okhttp3.**, okio.**, retrofit2.**
-dontwarn retrofit2.**
-keep class retrofit2.** { *; }
Than I tried adding @Keep annotation to my Model file as shown below:
@Keep
data class ChecksumResponseEntity(
@SerializedName("code")
val code: Double,
@SerializedName("message")
val message: String,
@SerializedName("checksum")
val checksum: String
)
Not sure why it was happening but adding @Keep fixed it for me.
Keep the package as it is, where the DTOs are :
-keep class com.test.apppackagename.retrofit.dto** {
*;
}
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