eclipse – How to fix Call requires API level 11 with Android Activity?

eclipse – How to fix Call requires API level 11 with Android Activity?

Use getSupportActionBar() instead of getActionBar(). That will provide ActionBar features on API levels below 11.

In short, Action Bar is not available in older versions of Android, and googles support library doesnt provide that feature either. This is the reason why lint is complaining – you are using code that doesnt exist in API verison 8 which is set as a minimum API level your app supports. If you want to use action bar on older android versions, use open source library called Action Bar Sherlock.

Now, to answer your questions

  1. This should be an error in both classes. The reason why its not an error in one of the classes is not actually important.
  2. No
  3. Its wrong in both activities
  4. You have to use open source library that provides action bar on older android versions, i.e. ActionBar Sherlock works great for this purpose
  5. The really right thing to do is to open Android Developers website and read about the limitations of support library.

eclipse – How to fix Call requires API level 11 with Android Activity?

if you use appcompat-v7 and higher you cant use actionbarsherlock because both have same attributes defined. so this libraries have a conflict in resources.

to do it with support library you need:
(i hope youve allready downloaded and integrated the support library in your project)

  1. you must use ActionBar from the support library, so you have to extends your activity
    with the right ActionBarActivity implementation.




public class PlacesActivity extends ActionBarActivity {

    public void onCreate(Bundle savedInstanceState) {
        // I manually commented out the following line to get it to compile.
        // getActionBar().setDisplayHomeAsUpEnabled(true);
    // ... other methods

so you can get the actionBar implemenation from Activity supported by older versions:

 ActionBar actionBar = activity.getSupportActionBar();

write code & have fun!

Leave a Reply

Your email address will not be published.