简体   繁体   English

错误:调用需要 API 级别 24(当前最小值为 21):java.util.Map#forEach [NewApi]

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

I have two enum class EventKey and EventProperty我有两个枚举class EventKeyEventProperty

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 级别 24Lint 认为 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.221.8.0碰到了这个 Kotlin

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.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.

相关问题 调用要求API级别21,当前最小值为8 - Call requires API level 21, current min is 8 需要API级别21(当前最小值为16) - Requires API level 21 (current min is 16) 调用需要 api 级别 24 java.util.comparator - call requires api level 24 java.util.comparator 错误:调用需要API级别23(当前最小值为15): - Error : Call requires API level 23(current min is 15): 调用要求API级别16(当前最小值为14),并带有EndAction - Call requires API level 16 (current min is 14) withEndAction 调用需要API级别26(当前最小值为23):java.time.Instant#now - Call requires API level 26 (current min is 23): java.time.Instant#now 调用需要api级别9(当前最小值为7)java.text.normalizer#normalize - call requires api level 9 (current min is 7) java.text.normalizer#normalize 如何修复 Android 中的“呼叫需要 API 级别 26(当前最小值为 25)”错误 - How to fix "Call requires API level 26 (current min is 25) " error in Android 我有一个错误“调用要求API级别11(当前最小值为8)”。 这是我在项目(ECLISPE)中可以找到的 - I have an error “Call requires API level 11 (current min is 8)”. This is what I can find in my project (ECLISPE) 调用需要 API 级别 23(当前最小值为 22)同时从应用程序发出调用请求 - Call requires API level 23 (current min is 22) While making a call request from App
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM