Call requires API level 14 (current min is 11)

adt, android

Solution

but why is ADT acting so smug telling me this doesn't belong there, when the call to that method is inside a block that checks the current version

Yes you added it but `IDE` know nothing about you are checking version through Build.

Just add @SuppressLint("NewApi") and error will disappear. Or you can create bellow methods and use them in conditions:

@TargetApi(14)
private void actionAPI14() {
   getActionBar().setHomeButtonEnabled(false);
}

private void action() {
   getSupportActionBar().setHomeButtonEnabled(false);
}

Always you can use support package for lower API versions.

Problem

I've been following the Android official training program, and on the lesson Managing the Activity Lifecycle » Starting an Activity, there is a piece of code that goes like this: ``` public void onCreate(Bundle savedInstanceState) { /* ... some other stuff ... */ // Make sure we're running on Honeycomb or higher to use ActionBar APIs if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { // For the main activity, make sure the app icon in the action bar // does not behave as a button ActionBar actionBar = getActionBar(); actionBar.setHomeButtonEnabled(false); } } ``` When I write it in my test application however, I get a warning from ADT saying Call requires API level 14 (current min is 11): android.app.ActionBar#setHomeButtonEnabled My app indeed is min API level 11, as it should be per the tutorial, but why is ADT acting so smug telling me this doesn't belong there, when the call to that method is inside a block that checks the current version? The training program continues to convince me that this is okay by saying: Caution: Using the SDK_INT to prevent older systems from executing new APIs works in this way on Android 2.0 (API level 5) and higher only. Older versions will encounter a runtime exception. But avoiding a runtime error doesn't help much, when ADT doesn't even let me compile this.

Original source