1
votes

I'm using Jackson to deserialize Kotlin data classes. I'm using the jackson-kotlin-module but Jackson is giving me the following error:

Can not construct instance of MyClass: no suitable constructor found, can not deserialize from Object value

I've tried adding proguard rules to keep my classes, and it's constructor without any success.

If I add a rule to keep all kotlin classes the error goes away.

Any ideas?

1
Your question did not have enough information for others to solve the issue, not showing code example or Proguard configuration.Jayson Minard

1 Answers

5
votes

After a lot of trial and error, I discovered that Proguard was stripping kotlin.Metadata annotations from my data classes.

Adding the following rule fixes the issue:

-keep class kotlin.Metadata { *; }

I also found adding a rule to keep synthetic methods on my data classes was needed too:

-keepclassmembers public class com.mypackage.** {
    public synthetic <methods>;
}