I have a package with some data classes and I'm trying to access the constructor at runtime using Kotlin reflection clazz.primaryConstructor
,
Everything is working as expected but when I enable R8, data classes metadata are removed so for example when I check if the KClass isData
it returns false and the primary constructor is also null which happens only when enabling R8.
I tried everything including adding the @keep
annotation to all data classes and adding a rule to keep everything in the models package, I also added these rules
-keep class kotlin.reflect.**
-keep class kotlin.Metadata { *; }
but still no luck, any idea what is going wrong or how to fix this ?
Thanks in advance.