'Proguard rules for Moshi models?
I have an Android app (Java) that uses Moshi 1.11.0 to work with JSON responses. Take this model as an example:
class Payments {
public float amount;
public int month, year;
}
When developing (and running debug variant), everything works perfectly. However, when building a release version, Proguard makes all properties become 0 when trying to read them from my model. (payment.amount, payment.month, payment.year are all 0).
So far, the only thing that has fixed this is by prepending the @Keep annotation before each and every one of my model declarations:
@Keep
class Payments {...}
My question is.. Is there any other workaround that would fix this issue, without having to modify each and every one of my models?
Solution 1:[1]
I found these keep rules online, can you try to add them to your configuration and see if that solves your problem (without manually adding the @keep annotations to your models)?
https://github.com/square/moshi/blob/master/moshi/src/main/resources/META-INF/proguard/moshi.pro
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Edevont |
