Manoj Majumdar Manoj Majumdar - 1 year ago 149
Java Question

Call requires API level 11(current min is 8)

I am a newbie to android, and I am developing an android application. But my package line gives this error in class.
Could anyone please tell me the reason of this?.
This is my class and the package line gives this error.

package com.example.eventgyaam;

import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

public class MainActivity extends AppCompatActivity {

int counter;

Button add,sub;
TextView display;

protected void onCreate(Bundle savedInstanceState) {
counter = 0;
add = (Button) findViewById(;
sub = (Button) findViewById(;
display = (Button) findViewById(;
add.setOnClickListener(new View.OnClickListener() {

public void onClick(View v) {
display.setText("Your total is "+counter);
sub.setOnClickListener(new View.OnClickListener() {

public void onClick(View v) {
display.setText("Your total is "+counter);



First, some introductory details.

There are levels of Android API and, at each level, they may introduce new functionality , as per here.

When you create an Android application, you specify the minimum level that your application will run on. This is done in the manifest with the uses-sdk stanza: see here for details.

So, if you use functionality that's only available at level 11, your code won't run on a level 8 API like you've specified.

You either have to use only what's available at your current minimum, or up the minimum.

As to why you appear to be getting the error on the package line, and for a call that doesn't seem to be in the source code you've shown us, I couldn't say. Since it's complaining about as per your title, there may be an issue with the view R.layout.activity_main that's being inflated by setContentView. Or it may be an issue with the compatibility library itself.

However, rather than struggling too hard with this, I would suggest simply upping the minimum to API-11 and dropping the appcompat stuff altogether. As per here, only about 5% of Android users are still back on releases earlier than Android-3.0/API-11 (as of August 2015). That's only likely to get smaller as time goes by.