Duplicate value for resource ‘android:attr/background‘ with config ‘DEFAULT‘ and product ‘‘

直接入题吧,具体的报错如下:

// 文件报错行1
/Users/xxx/AndroidStudioProjects/xxx/sdk/build/intermediates/packaged_res/debug/values/values.xml:390:4 

//background属性重复了已经定义过了
Duplicate value for resource 'android:attr/background' with config 'DEFAULT' and product ''. 
Resource was previously defined here: 

//文件报错行2
/Users/xxx/AndroidStudioProjects/xxx/sdk/build/intermediates/packaged_res/debug/values/values.xml:372:4:

首先看报错信息,background属性重复定义了.

怎样找呢?打开values.xml文件报错行:


    <declare-styleable name="ScaleViewStyle">
        // 这里无integer
        <attr format="reference|color" name="android:background"/>
        <attr format="reference|color" name="successBarsColor"/>
    </declare-styleable>

    <declare-styleable name="CreationViewStyle">
        <attr format="reference" name="android:textAppearance"/>
        // 这里integer多了个integer?二者未保持一致,,,,,,
        <attr format="reference|color|integer" name="android:background"/>
    </declare-styleable>

好吧values.xml是合并后的资源文件,找到自己自定义属性的attr.xml 让二者保持一致就行了~

猜你喜欢

转载自blog.csdn.net/qq_38350635/article/details/126782613
今日推荐