3

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

Kotlin Learner
  • 3,995
  • 6
  • 47
  • 127

1 Answers1

0

I run into this by bump Kotlin from 1.7.22 to 1.8.0

Error: Call requires API level 24 (current min is 21): java.lang.Iterable#forEach [NewApi]
            allArrived(clientHandle).forEach {
                                     ~~~~~~~

My solution

I bumped from

com.android.tools.build:gradle:7.3.1 to

com.android.tools.build:gradle:7.4.0 and now it's working for me

hannes ach
  • 16,247
  • 7
  • 61
  • 84