I have some classes used for Retrofit2, and serialized by Jackson.
@JsonIgnoreProperties(ignoreUnknown = true)
class GetUserRequest(
@JsonProperty("user_id")
var userId: String? = null
)
They work in debug builds, but when I do a release build with proguard or R8 minification enabled, it minifies the classes variables (as expected), but also whatever code is generated by @JsonProperty, causing the network request to be sent with json like { "a": "123" } instead of { "user_id": "123" }
I have included support for kotlin by jackson implementation "com.fasterxml.jackson.module:jackson-module-kotlin:2.9.9" implementation "com.squareup.retrofit2:converter-jackson:2.6.0"
And I have some proguard rules that work for my java class model objects.
-keep class com.fasterxml.jackson.databind.ObjectMapper {
public <methods>;
protected <methods>;
}
-keep class com.fasterxml.jackson.databind.ObjectWriter {
public ** writeValueAsString(**);
}
-keep class * {
@com.fasterxml.jackson.annotation.JsonCreator *;
@com.fasterxml.jackson.annotation.JsonProperty *;
}
-keepnames class com.fasterxml.jackson.** { *; }
-dontwarn com.fasterxml.jackson.databind.**
-keep class kotlin.Metadata { *; }
What proguard rules do I need to add so that Proguard does not minify the json properties?
I don't want to just exclude everything in my models package.