Elye
Elye

Reputation: 60211

Kotlin: Need to proguard Kotlin Data Class?

I have a data class defined as below

package com.mypackage.model

object Model {
    data class News(val photo: String, val title: String, val description: String)
}

When I compile it using Proguard (i.e. release build), the data I received and store in the model all becomes null. They are still there i.e. ArrayList listOfNews does have the expected retrieved size. However all their content is null.

Debug build this is okay. To solve this, I use this proguard rules, and it resolve the problem.

-keep class com.mypackage.model.** { *; }

Is this expected? i.e. all Data Class should be pro-guarded?

Upvotes: 5

Views: 3188

Answers (1)

tibbi
tibbi

Reputation: 249

as far as I can tell, that behavior is expected. It might be related to them being serializable or so. I also have to add the model classes to proguard.

Upvotes: 1

Related Questions