问题
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'
回答1:
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.
回答2:
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" />
回答3:
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>
来源:https://stackoverflow.com/questions/39347389/attribute-already-defined-with-incompatible-format-original-attribute-defined-h