As of AppCompat version 21, the Action Bar follows the material design guidelines and uses a Toolbar:

  • A title and subtitle. The title should be a signpost for the Toolbar's current position in the navigation hierarchy and the content contained there. The subtitle, if present should indicate any extended information about the current content. If an app uses a logo image it should strongly consider omitting a title and subtitle.

In modern Android UIs developers should lean more on a visually distinct color scheme for toolbars than on their application icon. The use of application icon plus title as a standard layout is discouraged on API 21 devices and newer.

However, if you want an application icon, setLogo() is the correct method.


Update your onCreate() method with the code below.

 @Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    getSupportActionBar().setDisplayShowHomeEnabled(true);
    getSupportActionBar().setLogo(R.drawable.ic_launcher);
    getSupportActionBar().setDisplayUseLogoEnabled(true);
    setContentView(R.layout.activity_main);
}

It worked for me. note: ic_launcher is the icon you want to display in your actionbar, for that you will have to add the icon in the drawable folder of your app project.


IN Style.xml

 <style name="MyTheme_ActionBar" parent="@style/Theme.AppCompat.Light">
   <item name="icon">@drawable/actionbar_logo</item>
  </style>

In activity add this and try

ActionBar mActionBar = getSupportActionBar();
mActionBar.setDisplayOptions(ActionBar.DISPLAY_HOME_AS_UP | ActionBar.DISPLAY_SHOW_CUSTOM | ActionBar.DISPLAY_SHOW_HOME);

If you don't care about the Material theme and are fine having an Activity that looks more JellyBean/Kitkat style and includes the icon in the Action Bar, you can do the following:

First, change themes setting in styles.xml from this:

<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">

To this:

<style name="AppTheme" parent="android:Theme.Holo.Light.DarkActionBar">

Now change all your Activities to inherit from android.app.Activity instead of android.support.v7.app.ActionBarActivity. That is:

Change this:

import android.support.v7.app.ActionBarActivity;

public class MainActivity extends ActionBarActivity{

To this:

import android.app.Activity;

public class MainActivity extends Activity {

The end of result of doing both of the above steps is that the icon as specified by the android:icon attribute in AndroidManifest.xml will appear in the Action Bar.