androidandroid-studioandroid-11

Android studio doesn't warn usage of new-api. Why?


My Android Studio version:

My project:

My snippet code:

myActivity.getWindowManager().getCurrentWindowMetrics();

Method getCurrentWindowMetrics() of class WindowManager is ONLY available on Android 11 (see here: https://developer.android.com/reference/android/view/WindowManager#getCurrentWindowMetrics())

My question:

why doesn't Android Studio warn me when calling new method:getCurrentWindowMetrics on older OS?


Solution

  • This bug happens when using navigation-fragment-ktx library version 2.4.x. It's fixed in recent versions, see a bug report.