运行报错崩溃:
Unable to start activity ComponentInfo{com.xxx.activity.SettingActivity}: 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.
起因是项目A中有如下的theme配置,然后把项目A作为module引入到项目B,运行报错
<style name="AppTheme" parent="Theme.MaterialComponents.DayNight.NoActionBar">
<item name="android:windowBackground">@color/windowBackground</item>
</style>
反正就是有个ActionBar的主题设置吧
然后在activity中调用了setSupportActionBar(toolbar)
val toolbar = findViewById(R.id.basic_toolbar)
setSupportActionBar(toolbar)
解决办法就是把theme改了:
<style name="AppTheme.NoActionBar" >
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
</style>
目前是这样就能正常运行,设置的toolbar样式也正常显示