In Android Studio, why android.util.ArrayMap.getOrDefault link to kotlin.collections.Map.getOrDefault?

47 Views Asked by At

I am using android.util.ArrayMap, which implements java.util.map, whose getOrDefault() function requires API level 24.

But I was not aware of these limit until crashes happened on low API devices, no warning showed in Android Studio.

Even when I click getOrDefault() function, I jump to kotlin.collections.Map.getOrDefault()

I am wondering why is this happening?

image

I hope this click could lead me to the correct definition of ArrayMap#getOrDefault(), and there is supposed to be a warning when I call this function.

1

There are 1 best solutions below

1
Miroslav Hýbler On

This warning works fine for me, try check your lint settings in: preferences -> editor -> inspections -> Calling new methods on older versions and make sure you have turned it on with some noticeable severity (Error is the best in my opinion).

enter image description here

With this settings i can see the error in Android Studio, hope it helps.

enter image description here