Let's say I have this class
data class Person(val name: String?)
When I proguard and run the app I am getting the following exception
kotlin.reflect.jvm.internal.KotlinReflectionInternalError: No accessors or field is found for property val com.whatever.packagee.Person.name: kotlin.String?
I also found that the issue is thrown from this reflection codebase. Any help would be appreciated
Please make sure to not use too broad -keep options, this will prevent ProGuard from properly optimising and shrinking the code.
It's important to preserve the fields of classes you wish to serialise. Based on the exception you see I would expect a -keep option similar to the one below would do the trick;
-keep class com.whatever.packagee.Person {
<fields>;
}
You can experiment with these -keep options via the ProGuard Playground, which is quite useful to see what parts of code are affected with your -keep rules. This way you can inspect if all cases of serialization were tackled. I created a Playground for this particular case: Playground link
This solved the issue for me.
Add following to proguard rules
-keep class kotlin.reflect.jvm.internal.**
-keep class kotlin.Metadata { *; }
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