I am using Kotlin MutableMap in my Android project. And an attempt to do some action for each item. So here is my code.
private val uris: MutableMap<String, Uri> = mutableMapOf()
uris.forEach {
val ref = FirebaseFirestore.getInstanse().reference
uploadFile(ref, it.value)
}
Everything works fine at runtime, but my CI build failed with an error below lint:
MyActivity.kt:142: Error: Call requires API level 24 (current min is 16): java.util.Map
uris.forEach {
~~~~~~~
I know that we cannot use the JDK-8 Map for Android projects until the min sdk is 24. But why does lint treat this as a JDK-8 map?
For more information, I tried to get Java code from the Kotlin Bytecode option in AS and found that forEach is being replaced by a while loop and an iterator, as expected.
So what could be the reason and how to solve it? Any guidance would be appreciated.
source
share