Reputation: 323
Recently I updated my target SDK to 29 as per new Android guidelines but after that I received this error:
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)' not found.
And my style XML file is:
<!-- 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>
How can I fix this?
This command followed by item names is showing the error: Theme.AppCompat.Light.DarkActionBar
Upvotes: 32
Views: 48413
Reputation: 235
This error commonly shows up when
androidx.appcompat:appcompat
and
com.google.android.material:material
versions do not match. Check whether you updated one and not the other. The versions should be the same for both.
Upvotes: 9
Reputation: 76579
Had this in a library module, which suddenly stopped resolving the theme.
dependencies {
implementation "com.google.android.material:material:1.3.0"
}
Upvotes: 14
Reputation: 663
Make sure you have not missed appcompat implementation in build.gradle(app)
implementation ‘com.android.support:appcompat-v7:28.0.0’
or
implementation 'androidx.appcompat:appcompat:1.2.0'
if using androidx
Upvotes: 31
Reputation: 191
Go to app/src/main/res/values/colors.xml It should look something like this:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="colorPrimary">#008577</color> //This is where the colorPrimary is defined
<color name="colorPrimaryDark">#00574B</color>
<color name="colorAccent">#D81B60</color>
</resources>
Make sure that the line that I commented exists, has correct syntax, and defines the appropriate 6-digit hexcode in the middle. The hexcode should be the primary color of the theme you are designing.
Upvotes: 1