Hi, I'm using moshi+retrofit and trying to sort ou...
# squarelibraries
p
Hi, I'm using moshi+retrofit and trying to sort out proguard setup I have a class:
Copy code
data class PingResponse(
    @Json(name = "needs_update") val shouldUpdate: Boolean,
)
And it works fine in debug, but with release minification it crashes with the following:
Copy code
IllegalArgumentException: No property for required constructor parameter #0 shouldUpdate of fun `<init>`(kotlin.Boolean): not.minimized.package.PingResponse
It works fine if I apply
@JsonClass(generateAdapter = true)
to class. As per documentation it sounds like I only need to apply
@JsonClass(generateAdapter = false)
to enums, and the rest should work out of the box. I find it very tricky that it works in debug without this annotation but fails in release. This comment suggests not minimizing all the models, but I don't find it much useful in my case, as I don't store all the models in one package. I can apply
@JsonClass(generateAdapter = true)
to all my models, the biggest issue is that if I forget to do that I won't know there's a problem until I run release version. Am I missing some other way to set it up, or is there a way to make app crash in debug(or build time check?), same as it does in release, in case when model has no
JsonClass
annotation?
z
Are you using code gen or reflection?
If the latter, you need to write keep rules for your own models like any other reflection
The enum doc is just for enums, doesn't imply anything about anything else
e
conversely, if you remove the reflection adapter, any Kotlin classes without
@JsonClass
will break, even in non-minified debug builds
p
Thank you both for sorting this out!
798 Views