Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unnecessary; SDK_INT is always >= 21, while my minSdkVersion is 16

So, I have a piece of code which looks something like

if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2){
    // Do something
} else {
    //Do something else
}

But Android Studio shows me the following warning for my if clause: Unnecessary; SDK_INT is always >= 21, while I have minSdkVersion set up to 16.

So, why am I getting this warning, even though Build.VERSION_CODES.JELLY_BEAN_MR2 = 18 and I might end up with a scenario in which this if clause must be useful (for example with 16 and 17 SDK version)?

like image 401
git pull origin Avatar asked Oct 15 '25 18:10

git pull origin


1 Answers

Silly me - just realized I also have flavors and the current one has minSdkVersion = 21. So, the check must stay to do its work for other flavors with lower minSdkVersions. Also, that means that Lint isn't able to check different flavors and sticks with the current one.

like image 146
git pull origin Avatar answered Oct 17 '25 07:10

git pull origin



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!