I\'m having app crash on resume because of Unmarshalling exception. I\'ve checked all the Serializables have constructor with no parameters and even checked all the serializ
Using Kotlin, the object 'Nota' has a Custom object 'CentroCusto' that contains only primitive properties.
class Nota(var id: Int? = null, var centroCusto: ArrayList? = null) : Parcelable {
constructor(source: Parcel) : this(
source.readValue(Int::class.java.classLoader) as Int?,
//Exception in below line -> Unmarshalling unknown type code
source.createTypedArrayList(CentroCusto.CREATOR)
)
override fun describeContents() = 0
override fun writeToParcel(dest: Parcel, flags: Int) = with(dest) {
writeValue(id)
writeTypedList(centroCusto)
}
companion object {
@JvmField
val CREATOR: Parcelable.Creator = object : Parcelable.Creator {
override fun createFromParcel(source: Parcel): Nota = Nota(source)
override fun newArray(size: Int): Array = arrayOfNulls(size)
}
}
The CentroCusto class:
class CentroCusto(var id: Int? = null, var descricao: String? = null, var aprovacaoDiretoria: Int? = null, var permiteMarcar: Boolean? = null) : Parcelable {
constructor(parcel: Parcel) : this(
parcel.readValue(Int::class.java.classLoader) as? Int,
parcel.readString(),
parcel.readValue(Int::class.java.classLoader) as? Int,
parcel.readValue(Boolean::class.java.classLoader) as? Boolean) {
}
override fun writeToParcel(parcel: Parcel, flags: Int) {
parcel.writeValue(id)
parcel.writeString(descricao)
parcel.writeValue(aprovacaoDiretoria)
parcel.writeValue(permiteMarcar)
}
override fun describeContents(): Int {
return 0
}
companion object CREATOR : Parcelable.Creator {
override fun createFromParcel(parcel: Parcel): CentroCusto {
return CentroCusto(parcel)
}
override fun newArray(size: Int): Array {
return arrayOfNulls(size)
}
}
}