My app has minSDKVersion 16.
I have followed the doc and added the following lines to my build.gradle in order to use some "Java 8 language APIs without requiring a minimum API level":
android {
compileOptions {
coreLibraryDesugaringEnabled true
}
}
dependencies {
coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:1.1.5'
}
This works as expected, and the following code does not crash at runtime on an API 16 emulator:
ArrayList<String> arr = new ArrayList<>();
arr.add("hello");
// ↓ this is a Java 8 API and crashes on API 16 if coreLibraryDesugaringEnabled=false
arr.removeIf(s -> true);
Now, the issue is that lint shows an error on this line:
Call requires API level 24 (current min is 16): java.util.ArrayList#removeIf
How can I fix this incorrect behavior of Android Studio/lint?
I don't want to suppress the error because it could be useful, when actually legitimate.
