I started receiving a weird crashes from MIUI 11 devices running Android 11 (so far only Mi 10 and Mi 10 lite 5G). I think this is a platform issue and nothing in my app as it's super specific to Xiaomi Android 11.
Fatal Exception: android.app.RemoteServiceException
Bad notification(tag=null, id=3249) posted from package de.crysxd.octoapp, crashing app(uid=10334, pid=23788): Couldn't inflate contentViewsjava.lang.NullPointerException: Attempt to invoke virtual method 'android.app.Notification$MessagingStyle android.app.Notification$MessagingStyle.setConversationType(int)' on a null object reference
I know similar crashes can happen if you e.g. use SVG icons on old devices, but I already use PNG. There are only two types of notification the device shows, one is a foreground service and one comes from Firebase. From the timing of the crash, it seems unlikely to be the Firebase notification.
Here is the code I use to create to notification (here in full):
private fun createProgressNotification(progress: Int, title: String, status: String) = createNotificationBuilder()
.setContentTitle(title)
.setContentText(status)
.setProgress(maxProgress, progress, false)
.setOngoing(true)
.addCloseAction()
.setNotificationSilent()
.build()
private fun createCompletedNotification(name: String?) = createNotificationBuilder()
.setContentTitle(getString(R.string.notification_print_done_title))
.apply {
name?.let {
setContentText(it)
}
}
.setSound(RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION))
.build()
private fun createDisconnectedNotification() = createNotificationBuilder()
.setContentTitle(getString(R.string.notification_printing_lost_connection_message))
.setContentText(lastEta)
.setProgress(maxProgress, 0, true)
.addCloseAction()
.setOngoing(false)
.setNotificationSilent()
.build()
private fun createInitialNotification() = createNotificationBuilder()
.setContentTitle(getString(R.string.notification_printing_title))
.setProgress(maxProgress, 0, true)
.setOngoing(true)
.addCloseAction()
.setNotificationSilent()
.build()
private fun createNotificationBuilder() = NotificationCompat.Builder(this, notificationChannelId)
.setColorized(true)
.setColor(ContextCompat.getColor(this, R.color.primary_light))
.setSmallIcon(R.drawable.ic_notification_default)
.setContentIntent(createStartAppPendingIntent())
Anyone having the same issue or knows a solution?
question from:
https://stackoverflow.com/questions/65650915/remoteserviceexception-crashing-my-app-on-miui-11 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…