Javanshir
Javanshir

Reputation: 792

Attribute already defined with incompatible format (Original attribute defined here)

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'

Upvotes: 7

Views: 13313

Answers (3)

Vahe Gharibyan
Vahe Gharibyan

Reputation: 5693

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>

Upvotes: 0

Lan
Lan

Reputation: 11

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" />

Upvotes: 1

Javanshir
Javanshir

Reputation: 792

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.

Upvotes: 4

Related Questions