Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to parcel value with type Any? using @Parcelize

I have encountered with a problem when trying to put value with type Any? into parcel. I'm using @Parcelize from kotlinx.android.parcel. Lint is warning me and hints with message to add @RawValue, but it's not helping. I got:

android.os.BadParcelableException: ClassNotFoundException when unmarshalling

My data class:

@Parcelize
    data class FormulaNode(
            val term: @RawValue Any? = null,
            val operator: String? = null,
            val left: FormulaNode? = null,
            val right: FormulaNode? = null) : Parcelable
like image 297
Skullper Avatar asked Nov 02 '18 10:11

Skullper


1 Answers

Follow this answer: https://stackoverflow.com/a/49606439/5857685

var tokenType: @RawValue Any? = null
like image 68
João Eudes Lima Avatar answered Oct 13 '22 01:10

João Eudes Lima