android的区别:Theme.Material.Light.DarkActionBar和Theme.AppCompat.Light.DarkActionBar

android的区别:Theme.Material.Light.DarkActionBar和Theme.AppCompat.Light.DarkActionBar,android,android-appcompat,android-theme,Android,Android Appcompat,Android Theme,当我使用以下样式时 <!-- Base application theme. --> <style name="AppTheme" parent="android:Theme.Material.Light.DarkActionBar"> <!-- Customize your theme here. --> </style> 我得到一个错误: java.lang.RuntimeException:无法启动活动 ComponentInf

当我使用以下样式时

<!-- Base application theme. -->
<style name="AppTheme" parent="android:Theme.Material.Light.DarkActionBar">
    <!-- Customize your theme here. -->
</style>

我得到一个错误:

java.lang.RuntimeException:无法启动活动 ComponentInfo{com.xx.xx/com.xx.xx.setup.SetupASelectLanguageActivity}: java.lang.IllegalStateException

当我将其更改为:

<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
    <!-- Customize your theme here. -->
    <item name="colorPrimary">@color/colorPrimary</item>
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
    <item name="colorAccent">@color/colorAccent</item>
</style>

@颜色/原色
@颜色/原色暗
@颜色/颜色重音
它没有错误

为什么?

主题 android:Theme.Material.Light.DarkActionBar。是否依赖于操作系统

而appcompat版本则显式添加到apk中。 此外,如果您正在使用AppcompatActivity,则最好使用 Appcompat主题它将避免冲突