Style attribute attr/colorSecondary not found

Had the similar problem after I added a car lib.

AAPT: error: style attribute 'attr/listChoiceIndicatorSingleAnimated (aka ****debug:attr/listChoiceIndicatorSingleAnimated)' not found.

That missing attribute was available in

implementation 'androidx.preference:preference:1.1.1'

Just check which lib the missing attribute is available in and add that as dep.


You need to explicitly define the 'attr' type in the item in AS 3.0

eg.

<item type="attr" name="colorPrimary">@color/primaryColor</item>

Docs: https://web.archive.org/web/20180518223123/https://developer.android.com/studio/build/gradle-plugin-3-0-0-migration

Also, don't forget to define the attribute in your attrs.xml. eg.

<declare-styleable name="Theme">
    <attr name="colorPrimary" format="color|reference" />
</declare-styleable>

The error you're getting is telling that the problem is that Theme named Theme.AppCompat.Light.NoActionBar doesn't contain attribute secondaryColor. So what you're basically trying to do is assign value to non-existent attribute.

Depending on your needs, you can choose from existing attributes (easiest way to get them is by pressing CTR + SPACE inside empty quotes in item name = "") , or just add regular color and use it directly in the layout or Java code.

Tags:

Styles

Android