Error: Call requires API level 24 (current min is 21): java.util.Map#forEach [NewApi]

Viewed 1172

I have two enum class EventKey and EventProperty

enum class EventKey(val firebaseKey: String? = null) {
       SIGNIN(firebaseKey = "singin"),
       .....
}

enum class EventProperty(val property: String) {
    TYPE1("type1"),
    ....
}

I am getting error on this

fun event(eventKey: EventKey, properties: Map<EventProperty, Any>) {
        eventKey.firebaseKey?.let { key ->
            properties?.forEach { entry ->
                eventData.put(entry.key.property, entry.value)
            }
        }
}

I tried this Kotlin Extension Functions suddenly require api level 24, Lint considers Kotlin MutableMap.forEach() as java.util.Map.forEach() and change the code

properties?.forEach { (entry) ->
     eventData.put(entry.property, entry)
}

or

properties?.forEach { (entry,value) ->
     eventData.put(entry.property, value)
 }

It giving the same error on lint checking, also what i am doing in code after changing the stack overflow answer.

Using Kotlin 1.5.20

0 Answers
Related