错误:未找到样式属性“attr/colorPrimary”

新手上路,请多包涵

最近我根据新的 Android 指南将我的目标 SDK 更新为 29,但之后我收到了这个错误:

D:\Android Apps\PatherPane\app\src\main\res\values\styles.xml:4:5-9:13: AAPT: 错误: 样式属性 ‘attr/colorPrimary (又名 com.patherpane.app:attr/ colorPrimary)’ 未找到。

我的样式 XML 文件是:

 <!-- Base application theme. -->
<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>
<style name="SplashScreen" parent="Theme.AppCompat.Light.NoActionBar">
    <item name="android:windowBackground">
        @drawable/background_splashscreen
    </item>
</style>

我怎样才能解决这个问题?

此命令后跟项目名称显示错误: Theme.AppCompat.Light.DarkActionBar

原文由 ProgrammerX 发布,翻译遵循 CC BY-SA 4.0 许可协议

阅读 2.5k
2 个回答

确保您没有错过 build.gradle (app) 中的 appcompat 实现

implementation ‘com.android.support:appcompat-v7:28.0.0’

要么

implementation 'androidx.appcompat:appcompat:1.2.0'

如果使用 androidx

原文由 alexmro 发布,翻译遵循 CC BY-SA 4.0 许可协议

在库模块中有这个,它突然停止解析主题。

 dependencies {
    implementation "com.google.android.material:material:1.3.0"
}

原文由 Martin Zeitler 发布,翻译遵循 CC BY-SA 4.0 许可协议

推荐问题