NullPointerException en android.support.v4.app.NotificationCompatBase $ Action.getIcon ()

alguien puede ayudar? Code mBuilder.build produce locking

 java.lang.NullPointerException: Attempt to invoke virtual method 'int android.support.v4.app.NotificationCompatBase$Action.getIcon()' on a null object reference 

Aquí está mi código

 private fun createNotification(pushMessage: FirebaseMessage){ Timber.d("Firebase") // create notification builder var mBuilder: NotificationCompat.Builder = if(SystemTools.isAtLeastOreo()) NotificationCompat.Builder(this, getChannelId(pushMessage)) else NotificationCompat.Builder(this) val inboxStyle = NotificationCompat.BigTextStyle() .setBigContentTitle(pushMessage.title) .bigText(pushMessage.message) // create notification view mBuilder.setSmallIcon(R.drawable.ic_notification_car) // have to use jpeg or png for notification icon (crash) // .setLargeIcon(BitmapFactory.decodeResource(baseContext.resources, R.mipmap.ic_launcher_round)) .setColor(ResourceUtils.getColor(baseContext, R.color.teal)) .setContentTitle(pushMessage.title) .setContentText(pushMessage.message) .setStyle(inboxStyle) .setContentIntent(getPendingIntent(pushMessage)) .setPriority(Notification.PRIORITY_HIGH) .addAction(createNotificationAction(pushMessage)) .setBadgeIconType(R.drawable.ic_notification_car) // send notification sendNotification(mBuilder.build()) } 

supportLibrary = '26.1.0' playServices = '11.4.0'

SOLUCIÓN:

  • Como exception, dijo: Action.getIcon() NullPointerException

Creé el uso de .addAction(createNotificationAction(pushMessage)) que generó la acción adecuada en function de pushMessage: FirebaseMessage . En caso de que pushMessage no coincida con nada, devolví null. Eso estaba causando una exception. Entonces, básicamente, no puedes ponerlo en NotificationBuilder.addAction(null)

La pregunta puede ser cerrada