Kotlin expansion features suddenly require api level 24

I just noticed this lint error:

A call requires API level 24 (current minimum is 19) java.util.map # foreach

when I use the extension function for Each on the MutableMap in Kotlin. This did not happen when I wrote the line, but now it is there. And I do not see this error on my other machine.

+2
source share
2 answers

What you use is not kotlin.collections.MutableMap.forEach.

What you use is similar Map.forEachin Java 8.

Read this article: http://blog.danlew.net/2017/03/16/kotlin-puzzler-whose-line-is-it-anyways/

This seems like a common mistake.

Java 8 is well supported from the Android 24 API level.

, map.forEach { t, u -> Log.i("tag", t + u) }.
map.forEach { (t, u) -> Log.i("tag", t + u) }.
( . , .)

+16

Map.forEach Java 8, Android API 24

0

Source: https://habr.com/ru/post/1692690/


All Articles