Attribute already defined with incompatible format (Original attribute defined here)
Asked Answered
P

3

7

Can't build project after adding

compile 'com.android.support:design:24.2.0'

Keeps giving the following errors:

Seems like, the problem is with supporting vector drawables. Somewhere some attributes are added twice.

For instance, built values.xml file contains:

<declare-styleable name="AppBarLayout_LayoutParams"><attr name="layout_scrollFlags"><flag name="scroll" value="0x1"/><flag name="exitUntilCollapsed" value="0x2"/><flag name="enterAlways" value="0x4"/><flag name="enterAlwaysCollapsed" value="0x8"/></attr><attr format="reference" name="layout_scrollInterpolator"/></declare-styleable>

and

<declare-styleable name="AppBarLayout_Layout"><attr name="layout_scrollFlags">
        <flag name="scroll" value="0x1"/>
        <flag name="exitUntilCollapsed" value="0x2"/>
        <flag name="enterAlways" value="0x4"/> 
        <flag name="enterAlwaysCollapsed" value="0x8"/>
        <flag name="snap" value="0x10"/>

I have this added to gradle file:

compile 'com.android.support:cardview-v7:24.2.0' + '@aar'
compile 'com.android.support:recyclerview-v7:24.2.0' + '@aar'
compile 'com.android.support:appcompat-v7:24.2.0'
compile 'com.android.support:design:24.2.0'
Pinfeather answered 6/9, 2016 at 10:59 Comment(5)
try to remove @aarSiderosis
Can't see any connection, but I still removed and checked. That is not the problemPinfeather
put your layout.xml in which you receive this errorSiderosis
Is your issue resolved ? i am having the same issue can you share how did you solved this ?Sot
I changed support library to an older version (all of them, and it worked). Recently changed to the newer version and it works without problem.Pinfeather
P
4

The problem appears when different versions of the same library present within the application. In this case, different versions of support library.

If you don't see them in your gradle file, then they are probably added as dependencies. Run the following in terminal, to see the dependencies for each library:

./gradlew app:dependencies

Then, find the libraries that use old versions of appcompat and update / remove, whatever suits you.

Pinfeather answered 3/3, 2017 at 11:59 Comment(0)
M
1

You have the same property name as the other controls, and modify the name of the property of your custom control

<declare-styleable name="MyBgView">
        <attr name="textString" format="string" />
        <attr name="textSizes" format="dimension" />
        <attr name="triangleSize" format="dimension" />
        <attr name="backgrounds" format="color" />
        <attr name="textColors" format="color" />

Merrill answered 13/7, 2017 at 10:5 Comment(0)
W
0

Android sdk is not avoid to extended attributes.Use up parent namespace

<declare-styleable name="AppBarLayout_Layout" parent="AppBarLayout_LayoutParams">
    <attr name="layout_scrollFlags">
</declare-styleable>
Warlock answered 3/11, 2017 at 15:13 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.