Do not request Window.FEATURE_ACTION_BAR issue

request window feature_support_action_bar
this activity already has an action bar supplied by
java lang illegalstateexception this activity already has an action bar supplied
windowactionbar''>false not working
android toolbar
custom toolbar'' android
toolbar not showing android
android custom toolbar layout

I'm trying to build my app but without success.. I tried several way but nothing was worked. The exception is:

Caused by: java.lang.IllegalStateException: This Activity already has an action bar supplied by the window decor. Do not request Window.FEATURE_ACTION_BAR and set windowActionBar to false in your theme to use a Toolbar instead.

My style.xml is:

<resources>

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

        <!-- theme customizations -->

        <item name="colorPrimary">@color/colorPrimary</item>
        <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
        <item name="colorAccent">@color/colorAccent</item>
        <item name="android:windowNoTitle">true</item>
        <item name="android:windowActionBar">false</item>

        <item name="android:textColorPrimary">@color/ldrawer_color</item>
        <item name="actionMenuTextColor">@color/ldrawer_color</item>
        <item name="android:textColorSecondary">@color/ldrawer_color</item>
    </style>

</resources>

and as you can see i have declared

<item name="android:windowNoTitle">true</item>
<item name="android:windowActionBar">false</item>

This is my manifest.xml

 <application
        android:allowBackup="true"
        tools:replace="android:icon"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name=".MainActivity"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

and my BaseActivity that i use to extend other activities

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;

public abstract class BaseActivity extends AppCompatActivity {

    public Toolbar toolbar;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(getLayoutResource());
        toolbar = (Toolbar) findViewById(R.id.toolbar);
        if (toolbar != null) {
            setSupportActionBar(toolbar);
            getSupportActionBar().setTitle(BaseActivity.this.getResources().getString(R.string.app_name));
            //getSupportActionBar().setDisplayHomeAsUpEnabled(true);
        }
    }

    protected abstract int getLayoutResource();

    protected void setActionBarIcon(int iconRes) {
        toolbar.setNavigationIcon(iconRes);
    }

}

I don't know why it crashes..The only way to start the application without crash is set the parent on the style.xml in Theme.AppCompat.Light.NoActionBar but in this way the status bar is transparent and not colored...

Using Theme.AppCompat.Light tells Android that you want the framework to provide an ActionBar for you. However, you are creating your own ActionBar (a Toolbar), so you are giving the framework mixed signals as to where you want the ActionBar to come from.

Since you are using a Toolbar, you want Theme.AppCompat.Light.NoActionBar.

The next step is to make sure your Toolbar is styled correctly, which seems to be where you are running into issues. To style your Toolbar like an ActionBar using the colors you defined for your theme, you need to provide a theme like so:

<android.support.v7.widget.Toolbar
    android:layout_height="wrap_content"
    android:layout_width="match_parent"
    android:minHeight="?attr/actionBarSize"
    app:theme="@style/ThemeOverlay.AppCompat.ActionBar" />

See the "styling" section for the Toolbar widget on this Android Developers blog post for more information.

Do not request Window.FEATURE_SUPPORT_ACTION_BAR and , Do not request Window.FEATURE_SUPPORT_ACTION_BAR and set windowActionBar to false in your theme to use a Toolbar instead. The problem is that I� This Activity already has an action bar supplied by the window decor. Do not request Window.FEATURE_ACTION_BAR and set windowActionBar to false in your theme to use a Toolbar instead This is the e

Assuming you got this lines in styles.xml:

<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
    <item name="colorPrimary">@color/colorPrimary</item>
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
    <item name="colorAccent">@color/colorAccent</item>
</style>

Add these extra lines after:

<style name="AppTheme.NoActionBar">
    <item name="windowActionBar">false</item>
    <item name="windowNoTitle">true</item>
</style>

Then add this to your activity in manifest:

<activity android:name=".activity.YourActivity"
          android:theme="@style/AppTheme.NoActionBar"><!-- ADD THIS LINE -->

That was best solution for me after checking tutorials and other solutions

Do not request Window.FEATURE_ACTION_BAR issue, Do not request Window.FEATURE_ACTION_BAR issue. 9月. 04. 2019. By 月下凤仪亭. I'm trying to build my app but without success.. I tried several way but� Error: java.lang.IllegalStateException: This Activity already has an action bar supplied by the window decor. Do not request Window.FEATURE_ACTION_BAR and set windowActionBar to false in your theme to use a Toolbar instead.

In my case, I created a new activity and forgot to define it's app:theme in AndroidManifest.xml:

 <activity
        android:name=".HistoryActivity"
        android:label="History"
        android:theme="@style/AppTheme.Primary"></activity>

Do not request Window.FEATURE_ACTION_BAR and set , Hi, I'm having this issue when I applied the toolbar into my app and it crashed when I try to run the app.I used all previous post but no luck. Do not request Window.FEATURE_ACTION_BAR and set windowActionBar to false in your theme to use a Toolbar instead Tag: android , mvvmcross , toolbar I'm having this issue when I applied the toolbar into my app and it crashed when I try to run the app.I used all previous post but no luck.

I have solved the problem after changing the value for the "android:theme" for the Activity in the manifest from "@style/AppTheme" to "@style/AppTheme.NoActionBar":

<activity android:name=".MyXXXActivity"
            ...                android:theme="@style/AppTheme.NoActionBar" />

Window, If the color is not opaque, consider setting View. above window content, but if this feature is requested along with FEATURE_ACTION_BAR it� Do not request Window.FEATURE_ACTION_BAR and set I'm having this issue when I applied the toolbar into my app and it crashed when I try to run the app.I used all

<style name="AppTheme.NoActionBar">
    <item name="windowActionBar">false</item>
    <item name="windowNoTitle">true</item>
</style>

 <android.appcompat.widget.Toolbar
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:theme="@style/AppTheme.NoActionBar">

 </android.appcompat.widget.Toolbar>
 <activity android:name=".activity.activity_name"
           android:theme="@style/AppTheme.NoActionBar">
 </activity>

Do not request Window.FEATURE_ACTION_BAR and set w, I'm having this issue when I applied the toolbar into my app and it crashed when I try to run the app.I used all previous post but no luck. Here is� Possible duplicate of Do not request Window.FEATURE_ACTION_BAR issue – ʍѳђઽ૯ท Jan 25 '16 at 10:07 add a comment | 6 Answers 6

This Activity already has an action bar supplied by the , bar supplied by the window decor. Do not request Window. by the window decor #34. Open. waar19 opened this issue on Feb 5, 2017 � 5 comments. Open � Caused by: java.lang.IllegalStateException: This Activity already has an action bar supplied by the window decor. Do not request Window.FEATURE_ACTION_BAR and set windowActionBar to false in your theme to use a Toolbar instead. I have already gone through these links but not working link link2. style.xml

java.lang.RuntimeException: Unable to start activity ComponentInfo , Do not request Window.FEATURE_ACTION_BAR and set windowActionBar to false in your theme to use a Toolbar instead. This crash was crawled from Stack� Caused by: java.lang.IllegalStateException: This Activity already has an action bar supplied by the window decor. Do not request Window.FEATURE_ACTION_BAR and set windowActionBar to false in your theme to use a Toolbar instead. at android.support.v7.app.ActionBarActivityDelegateBase.setSupportActionBar(ActionBarActivityDelegateBase.java:165)

This Activity already has an action bar supplied by the window decor , Such an error may occur when using the actionbar Do not request Window. FEATURE_ACTION_BAR and set android:windowActionBar to false in your Twenty of the Android problem collection Activity has leaked window that was originall. Do not request Window.FEATURE_ACTION_BAR and set windowActionBar to false in your theme to use a Toolbar instead. at android.support.v7.app

Comments
  • Ok seems it's working..i think the problem was the app:theme of the toolbar. Thanks!
  • Please explain your solution instead of just giving code
  • first of all you have to write this code which is below in the values/style. <style name="AppTheme.NoActionBar"> <item name="windowActionBar">false</item> <item name="windowNoTitle">true</item> </style> After that write this into your main_activity..<android.appcompat.widget.Toolbar android:theme="@style/AppTheme.NoActionBar"></android.appcompat.widget.Toolbar> in the last you just need to write last code into your manifest.xml: