属性已使用不兼容的格式定义(此处定义了原始属性) [英] Attribute already defined with incompatible format (Original attribute defined here)
问题描述
添加后无法构建项目
compile 'com.android.support:design:24.2.0'
保持以下错误:
似乎,问题在于支持矢量可绘制对象。在某些地方两次添加了某些属性。
Seems like, the problem is with supporting vector drawables. Somewhere some attributes are added twice.
例如,内置的values.xml文件包含:
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>
和
<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"/>
我已将此文件添加到gradle文件中:
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'
推荐答案
当应用程序中存在相同库的不同版本时,就会出现问题。在这种情况下,支持库的版本会有所不同。
The problem appears when different versions of the same library present within the application. In this case, different versions of support library.
如果您在gradle文件中看不到它们,则可能会将它们添加为依赖项。在终端中运行以下命令,查看每个库的依赖项:
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
然后,找到使用旧版本的appcompat的库,并根据需要进行更新/删除。
Then, find the libraries that use old versions of appcompat and update / remove, whatever suits you.
这篇关于属性已使用不兼容的格式定义(此处定义了原始属性)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!