[英]Error: Call requires API level 24 (current min is 21): java.util.Map#forEach [NewApi]
I have two enum class EventKey and EventProperty我有两个枚举class EventKey和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我试过这个Kotlin 扩展函数突然需要 api 级别 24 , Lint 认为 Kotlin MutableMap.forEach() 为 java.util.Map.forEach()并更改代码
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.它在 lint 检查中给出了相同的错误,还有我在更改堆栈溢出答案后在代码中所做的事情。
Using Kotlin 1.5.20使用 Kotlin 1.5.20
I run into this by bump Kotlin from 1.7.22
to 1.8.0
我从
1.7.22
到1.8.0
碰到了这个 Kotlin
Error: Call requires API level 24 (current min is 21): java.lang.Iterable#forEach [NewApi]
allArrived(clientHandle).forEach {
~~~~~~~
I bumped from我从
com.android.tools.build.gradle:7.3.1
to com.android.tools.build.gradle:7.3.1
至
com.android.tools.build.gradle:7.4.0
and now it's working for me com.android.tools.build.gradle:7.4.0
现在对我有用
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.