I’m getting a PROPERTY_WONT_BE_SERIALIZED warning ...
# announcements
j
I’m getting a PROPERTY_WONT_BE_SERIALIZED warning when using the new Parcelize annotation.
Copy code
@Parcelize
class ExampleClass : Parcelable {

    var id: Long? = 0
    var name: String? = null
    var tagName: String? = null
    var enabled: Boolean = false
Do my properties have to be constructor parameters?
l
yes, they do
I'm using right now as this
Copy code
@Parcelize
class Recipe(
        var id: String = "",
        val name: String = "",
        val cookTime: String = "",
        val serves: Long = -1L,
        val thumbnailUrl: String = "",
        val skillLevel: String = ""
) : Parcelable
can also be a data class instead
j
@leosan Cool thanks, now the compiler is complaining that “This class implements parcelable but does not provide a CREATOR class”
l
Yeah I'm having the same, just ignore it. It still works
Probably because Android Studio don't know about
@Parcelize
so it show that warning that you must implement the
Parcelable
j
I’m getting a run time crash
Copy code
java.lang.NoClassDefFoundError: Failed resolution of: com/example/example/data/config/ExampleClass$Creator
Ahh, you can’t have a companion object already defined in a @Parcelize class
👍 1
k
You should update your Android studio plugin if you haven’t done so. Also, if this is a class that will be unserialized from json for example, instead of using unnecessary defaults, you could consider the
no-args
plugin
l
@kingsley My Kotlin AS Plugin is up to date but I never heard of this
no-arg
plugin I will take a look, I'm essentially using this because firebase fails without a default value
k
l
just implemented 😮 worked like a charm, thanks for tip, code looking a lot cleaner now
👍 1
k
You’re welcome 🙂