android – java.lang.NoClassDefFoundError $$inlined$forEach$lambda$1 in Kotlin-ThrowExceptions

Exception or error:

I am currently working on an Android application with Kotlin in version 1.1.1

In my code, I have imbrication of several forEach structures in order to read several MutableList and MutableMap.

Unfortunately, my app crashes with the following stacktrace :

at at

Here the code

tutorialCategories.forEach { (_, _, _, _, _, tutorials) ->
  tutorials.forEach { tutorial ->
    if ( == simpleReminderFromExtra.tutorialId)
      val mapOfreminders = mutableMapOf<Int, MutableList<Reminder>>()
      val reminders = ReminderServices.getReminderByTutorialId(simpleReminderFromExtra.tutorialId)

      reminders.forEach { reminder ->

      mapOfreminders.forEach { _, finalReminders ->

        finalReminders.forEach { reminder ->


Where :

  • tutorialCategories is a List ;
  • tutorials is a List ;
  • reminders is a List ;

The line 275 of the code is mapOfreminders.forEach { _, finalReminders ->.

In the debugger, I can evaluate the mapOfreminders variable and everything seems to be alright.

If someone can help to resolve this issue !

How to solve:

After reading Dan Lew’s post a couple days ago, I’ll make a suggestion that this can be caused by using Map.forEach { k, v -> } method from Java 8, which may be unavailable in Android runtime.

You could try to use another forEach with the single entry parameter that comes from the Kotlin standard library:

mapOfreminders.forEach { (_, finalReminders) -> }

Here the parentheses are used to destructure entry parameter into two variables: ignored key and finalReminders value.


I encountered this problemjava.lang.NoClassDefFoundError on Android 6.0 and 6.0.1 by using

Map.forEach {key ,value -> }

this call java 8 api.

And then, I solved this problem by adding brackets to parameter:

Map.forEach {(key ,value) -> }

this call kotlin api


Seems like this particular error doesn’t happen on all phones. I faced a similar issue with Samsung Galaxy S7, where the app was crashing with ClassNotFoundError. This solution works if we still want to use lambda.
Else replacing the lambda with for ((key, value) in map) { ... }also works.

Leave a Reply

Your email address will not be published. Required fields are marked *