Proguard - do not obfuscate Kotlin data classes

To fix the problem I moved the model classes to model package and added new ProGuard rule for the package.

-keep class** { *; }

Another solution would be to use @Keep annotation from support library to disable the obfuscation for the class:

data class MyRequestBody(val value: String)

Using @Keep may cause problems because it's easy to forget to add it for new classes.

Hopefully in future there will be a way with one ProGuard rule to disable the obfuscation for all Data classes in package without the need to have a sub-package for the model classes.

While @Keep annotation works, another option is to add @SerializedName to the properties:

data class SomeDataClass(
    @SerializedName("prop1") val PropertyOne: String, 
    @SerializedName("prop2") val PropertyTwo: Boolean

I'm not sure keeping whole data class is good or not. but if it's requirement, the below proguard rule will work. but, this is just workaround. I suggest without confidence. please consider carefully.

-keepclasseswithmembers class example.data_layer.** {
    public ** component1();

I have an article here with a more detailed explanation: How to make Proguard keep Kotlin data class