转自https://www.cnblogs.com/hh9601/p/6404728.html # 异常信息:
1 | Caused by: java.lang.IllegalStateException: This Activity already has an action bar supplied by the window decor. Do not request Window.FEATURE_SUPPORT_ACTION_BAR and set windowActionBar to false in your theme to use a Toolbar instead. |
当在有activity
中调用了setSupportActionBar(toolbar);
而当前使用的主题为默认,或者带默认ActionBar
的主题

当在activity
中调用了setSupportActionBar(toolbar)
;
同时,AndroidManifest.xml
对应的Activity
标签的android:theme
为
<android:theme="@style/AppTheme" >
且,style资源文件中的parent为parent="Theme.AppCompat.Light.DarkActionBar

就会报这个异常。
解决方法:
在style.xm
l中加入:

在Manifest.xml
中,修改theme
