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

androidandroid-appcompatandroid-support-designgradle

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'

Best Answer

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.

Related Topic