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

Pro*_*erX 13 xml android android-studio

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

D:\Android Apps\PatherPane\app\src\main\res\values\styles.xml:4:5-9:13: AAPT: error: style attribute 'attr/colorPrimary (aka 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>
Run Code Online (Sandbox Code Playgroud)

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

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

Mar*_*ler 12

将其放在库模块中,该模块突然停止解析主题。

dependencies {
    implementation "com.google.android.material:material:1.3.0"
}
Run Code Online (Sandbox Code Playgroud)


ale*_*mro 11

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

implementation ‘com.android.support:appcompat-v7:28.0.0’
Run Code Online (Sandbox Code Playgroud)

或者

implementation 'androidx.appcompat:appcompat:1.2.0'
Run Code Online (Sandbox Code Playgroud)

如果使用androidx


Adh*_*ier 5

这个错误通常出现在

androidx.appcompat:appcompat
Run Code Online (Sandbox Code Playgroud)

com.google.android.material:material
Run Code Online (Sandbox Code Playgroud)

版本不匹配。检查您是否更新了一个而不是另一个

  • 如何找到匹配版本表?你怎么知道哪个compileSdkVersion需要哪个appcompat? (2认同)