Last Updated
Viewed 907 Times

I am having trouble compiling and running the ActionBarCompat sample of Android 16. I have API level 16 as the build target selected, which seems to build fine, but when I try to debug these errors pop up. Of course I could change the min API level in the manifest, but what would be the point of that? I have made no changes to the sample, so how come it is not working properly?

Class requires API level 14 (current min is 3): android.view.ActionProvider /ActionBarCompat/src/com/example/android/actionbarcompat    line 129    Android Lint Problem

Class requires API level 14 (current min is 3): android.view.ActionProvider /ActionBarCompat/src/com/example/android/actionbarcompat    line 134    Android Lint Problem

Class requires API level 14 (current min is 3): android.view.MenuItem.OnActionExpandListener /ActionBarCompat/src/com/example/android/actionbarcompat    line 155    Android Lint Problem

I am thoroughly confused, any help would be appreciated.

UPDATE: I have added the @TargetApi(14) annotations, then added Lint suppres newApi to one of the methoeds and now it seems to be running fine. I am even more confused. Could anybody shed some light on what's going on?

I'm following a tutorial on ActionBarCompat that also enables a search text area. I extended the ActionBarActivity from the v7 support lib. When I try to override these two methods it can't find them in the superclass. I went to source and looked at the superclass' methods and I can't locate them there as well. The two methods are onQueryTextSubmit and onQueryTextChange This was the tutorial.

Any idea what I am doing wrong?

This is the error when I hover over the methods:

The method onQueryTextChange(String) of type MainActivity must override or implement a supertype method

public class MainActivity extends ActionBarActivity{
private SearchView mSearchView;

protected void onCreate(Bundle savedInstanceState) {

    try {
        ViewConfiguration config = ViewConfiguration.get(this);
        Field menuKeyField = ViewConfiguration.class.getDeclaredField("sHasPermanentMenuKey");
        if(menuKeyField != null) {
            menuKeyField.setBoolean(config, false);
    } catch (Exception ex) {
        // Ignore


public boolean onQueryTextSubmit(String s) {
    Toast.makeText(this, s, Toast.LENGTH_LONG).show();
    return true;

public boolean onQueryTextChange(String s) {
    return false;
public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(, menu);

    MenuItem searchItem=menu.findItem(;
    mSearchView = (SearchView) MenuItemCompat.getActionView(searchItem);
    return true;

public boolean onOptionsItemSelected(MenuItem item) {

        return true;


    return false;

OK, I have been wanting to try the new ActionBarCompat, however, I am not able to run my programs in the emulator.

I have been trying to implement the following:

and have been stuck on basically the first part. However, working with the author of that content, I was able to get further as I was not adding the project under sdk\extras\android\support\v7\appcompat folder like stated. However, I still think that might be the reason I cannot do this...

More detail can be found here:

Basically, on my first attempt, I just created an Android project, and changed the source code as indicated. Code would not run on the emulator. So I went back to the original code, and that ran on the emulator.

Checked online, found out I might need to add the \extras\android\support\v7\appcompat folder as a library to the project I am building. So I added that and a new android project was created. There were build errors from the start, but I failed at trying to add it as a library to my project, and deleted it....thinking this was way overboard.

After back and forth chats with author of linked website, I found out I had to do that overboard thing.

So I tried the following link to the T: (I cannot post more than 2 links due to low repuation...I will add this link as a comment below)

However, Eclipse would not allow me to add the appcompat Existing Android Project...but it did allow me to add the appcompat Existing (General) Project. I think this may be some of the problems??

Right now, I cannot run the project at all. Eclipse is showing a red exclamation mark on the project folder, but all the code seems to be fine. So I don't know what to do now...I recreated this project several times over, and this one was the one where I knew what to do...and I am still getting problems


I decided to move to Android Studio...updated the IDE, updated the SDK manager to include the new support library, and other things. Created a new project, added to the build.gradle file as shown in the link provided below in the comment. I ran the ant build, and then built the project...tried to import the right things to allow ActionBarActivity, but I could not get that far.

I can import

""    // and all folders within

but nothing allows me to add ActionBarActivity, and I don't know why.

FYI, I guess I would prefer a solution to Ecplise, as it seems like I actually got somewhere with it.

I am attempting to style the ActionBarCompat title text, I was not able to find any native ActionBarCompat methods to do the three things I needed to do which were change the text color to white, add some padding to the bottom of the text, and change the text typeface, after some googling I was able to find a method that did this by referencing the title textview by id like this and applying the changes as normal

    int titleId = Resources.getSystem().getIdentifier("action_bar_title",
            "id", "android");

    actionBarText = (TextView) findViewById(titleId);

    actionBarText.setPadding(0, 0, 0, 10);      

However the problem that I have is when the device rotates the screen and changes the orientation the title text resets to its default black color, original padding and regular typeface, whats even worse is it appears that the changes I had made can only be done in the OnCreate method and when I try to set it back the way I want in code it will not work the second time for some reason, does anyone know a way I can make the chages I need and keep it permanent or at the very least reset it if needs be? any help will go a long way, thanks

Similar Question 5 (2 solutions) : Can't modify Navigation drawer using supportv7

Similar Question 8 (1 solutions) : ActionBarCompat and MapActivity

Similar Question 9 (2 solutions) : ActionBarCompat in FragmentActivty