The app is designed to create local notification based on various circumstances. MyReceiver class extends BroadCastReceiver. in onReceive method of the MyReceiver class i’m getting the intent value using
intent?.let {
val notification: MyTestObject? =
** (it.extras?.getBundle(BUNDLE) as Bundle).serializable(** // Crash occurs in this line
NOTIFICATION, MyTestObject::class.java
) as MyTestObject?
}
.serializable is a utility class where the code looks like this
fun <T : Serializable> Bundle.serializable(key: String, clazz: Class<T>) =
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
this.getSerializable(key, clazz)
} else {
**@Suppress("DEPRECATION") this.getSerializable(key)** // Crash occurs in this line
}
MyTestObject extends a Serializable that contains parameters to show title, message and some other info for showing the notificaiton
Firebase logged crash like this
Caused by java.io.InvalidClassException
package.MyTestObject ; local class incompatible: stream classdesc serialVersionUID = 5633808751232699642, local class serialVersionUID = 2428744743958317109
inorder to resolve this error we added private const val serialVersionUID: Long = 5633808751232699642 to the MyTestObject.
But now we are getting the same crash like this
Caused by java.io.InvalidClassException
com.abbvie.mycare.notifications.domain.entity.MyCareNotification; local class incompatible: stream classdesc serialVersionUID = 2428744743958317109, local class serialVersionUID = 5633808751232699642