https://kotlinlang.org logo
#android
Title
# android
g

Gilles Braun

08/29/2018, 11:22 AM
Hey guys I just encountered a weird bug(?) when using
Map.forEach
in Android. The reported exception is
java.lang.NoClassDefFoundError  com.example.packagename.AdManager$executeQueuedCalls$1
I found the solution on stackoverflow already, https://stackoverflow.com/a/51215937/7684435 My code looked like this before the fix:
grouped.forEach { type, interactions -> TODO("placeholder") }
, and the kotlin compiler chose the
Map.forEach(BiConsumer<? super K, ? super V> action)
, which uses
java.util.function.BiConsumer
which isn't available on Android < 8 Oreo. Occured with kotlin version 1.2.30, also with 1.2.61, using this gradle config:
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
I am not sure if this would be considered a bug or not
d

diego-gomez-olvera

08/29/2018, 11:25 AM
g

Gilles Braun

08/29/2018, 1:33 PM
okay thanks for the references