Hi there can somebody please advise me if there are any specific rules required for Kotlin class with enum? Simple example as
data class Passenger(
var type: Type?,
var id: Int,
var age: Int
) {
companion object {
const val AGE_NOT_SET = -1
}
enum class Type {
ADULT, CHILD, INFANT
}
constructor() : this(null, 0, 0)
}
If object get initialized to Passenger(CHILD, 123456, 4)
converted to Json and later on parsed back to POJO it will result in Passenger(null, 0,0)
I do have
-keepclassmembers,allowoptimization enum * {
public static **[] values(); public static ** valueOf(java.lang.String);
}
in my proguard rules that works for enum in Java but for some reason it fails for Kotlin
It looks like you need to keep all public enum class members to avoid this error. This worked for me:
-keepclassmembers enum * {
public *;
}
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