Style attribute attr/colorSecondary not found

前端 未结 3 1771
走了就别回头了
走了就别回头了 2020-12-18 21:15

I can\'t build my project. It shows me attr/colorSecondary not found error.

These are my styles and manifest files:

Android studi

相关标签:
3条回答
  • 2020-12-18 21:21

    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>
    
    0 讨论(0)
  • 2020-12-18 21:22

    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.

    0 讨论(0)
  • 2020-12-18 21:25

    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.

    0 讨论(0)
提交回复
热议问题