I am trying to change the style attributes from the Material Components Theme (like colorPrimaryVariant
, colorOnSecondary
and so on) but I get the following error:
Android resource linking failed
Output: C:\...\app\build\intermediates\incremental\mergeDebugResources\merged.dir\values\values.xml:3835: error: style attribute 'attr/colorPrimaryVariant (aka com.sample.app:attr/colorPrimaryVariant)' not found.
C:\...\app\build\intermediates\incremental\mergeDebugResources\merged.dir\values\values.xml:3836: error: style attribute 'attr/colorOnPrimary (aka com.sample.app:attr/colorOnPrimary)' not found.
C:\...\app\build\intermediates\incremental\mergeDebugResources\merged.dir\values\values.xml:3839: error: style attribute 'attr/colorSecondaryVariant (aka com.sample.app:attr/colorSecondaryVariant)' not found.
C:\...\app\build\intermediates\incremental\mergeDebugResources\merged.dir\values\values.xml:3840: error: style attribute 'attr/colorOnSecondary (aka com.sample.app:attr/colorOnSecondary)' not found.
error: failed linking references.
This is what my theme looks like:
<resources>
<!-- Light application theme -->
<style name="CBTheme" parent="Theme.MaterialComponents.Light.DarkActionBar">
<item name="colorPrimary">@color/cbPrimary</item>
<item name="colorPrimaryDark">@color/cbPrimaryDark</item>
<item name="colorPrimaryVariant">@color/cbPrimaryDark</item>
<item name="colorOnPrimary">#FFFFFF</item>
<item name="colorAccent">@color/cbAccent</item>
<item name="colorSecondary">@color/cbAccent</item>
<item name="colorSecondaryVariant">@color/cbAccentLight</item>
<item name="colorOnSecondary">#FFFFFF</item>
<item name="colorError">@color/cbRed</item>
<item name="android:windowBackground">@color/lightThemeBackground1</item>
</style>
[...]
</resources>
If I don't add the four affected attributes everything works fine. My minSdkVersion is 16, compileSdkVersion and targetSdkVersion are 28. I also tried to use the Bridge themes but I get the same error. I double-checked my dependencies and everything seems correct. What am I missing?
Theme.AppCompat
and if you read it carefully, I think it is available with theAppCompat
theme and those are new attributes for theAppCompat
to test and not theTheme.MaterialComponents
: You can also incrementally test new Material components without changing your app theme – Playoff