NoClassDefFoundError when posting a Runnable to Handler


I have a fairly simple block of code to clear a notification from the UI:

fun markNotificationRead(notificationId: String) { {
        if (notifications.removeIf { == notificationId }) {
            notificationLiveData.value = notifications

I can’t reproduce this on my device but I get rare crashes on Firebase saying:
NoClassDefFoundError: com.example.service.WebSocket$markNotificationRead$1$1

It looks like $ is throwing the exception? Is my lambda not being added to the dex?


I have the same problems.

var payloads = mutableListOf<Payload>()
override fun onObjectRemoved(object: MyClass) {
    payloads.removeIf { it. objectId == object. objectId }
    onPayloadUpdate(dayOfYear = dayOfYear)

The same issue is with replaceAll

It’s okay on Android 7, but 100% crashes on devices/emulators with Android 5/Android 6 .


Look at the [documentation](<? super E>), removeIf was added to java 8 and in android was only available from api level 24.


Thanks! Adding the Guava library and using it instead did the trick. I was using the kotlin implementation of the array and assumed that they provided the 1.8 features in the library.