[英]Android design support and other library give gradle build error: “headerLayout” has already been defined
I would like to add the design suppport library (com.android.support:design:22.2.0) but I got this error message: 我想添加设计支持库(com.android.support:design:22.2.0),但出现了以下错误消息:
"headerLayout" has already been defined
“ headerLayout”已经定义
I tried to find which library use this from my library list and maybe this one: https://github.com/traex/ExpandableLayout 我试图从我的图书馆列表中找到哪个图书馆在使用它,也许是这个图书馆: https : //github.com/traex/ExpandableLayout
How can I use theme same time? 如何同时使用主题? Thank you!
谢谢!
Edit: here is some detail: 编辑:这是一些细节:
Error:(1) Attribute "headerLayout" has already been defined ...
错误:(1)属性“ headerLayout”已定义...
...debug\\values\\values.xml:440: error: Attribute "headerLayout" has already been defined
... debug \\ values \\ values.xml:440:错误:属性“ headerLayout”已经定义
And this is the 440. line: 这是440行:
<declare-styleable name="NavigationView">
<attr name="android:background"/><attr name="android:fitsSystemWindows"/>
<attr name="android:maxWidth"/><attr name="elevation"/>
<attr format="reference" name="menu"/>
<attr format="color" name="itemIconTint"/>
<attr format="color" name="itemTextColor"/>
<attr format="reference" name="itemBackground"/>
<attr format="reference" name="headerLayout"/>
</declare-styleable>
and I found another item with this reference name, which is come from ExpandableLayout: 并且我找到了另一个具有此引用名称的项目,它来自ExpandableLayout:
<declare-styleable name="ExpandableLayout">
<attr format="reference" name="headerLayout"/>
<attr format="reference" name="contentLayout"/>
<attr format="integer" name="duration"/>
</declare-styleable>
What is the solution? 解决办法是什么? Because I can't modify these properties.
因为我无法修改这些属性。
It would be more useful if you post your Error log and a code snippet for the affected code. 如果发布您的错误日志和受影响代码的代码片段,它将更加有用。
It does not seem like a dependency error, check to see if you have a variable called headerLayout and see you have that declared more than once. 它似乎不像是一个依赖项错误,请检查是否有一个名为headerLayout的变量,并查看是否已多次声明该变量。
Edit: 编辑:
A workaround would be to change one of the name "headerLayout" to something else. 一种解决方法是将名称“ headerLayout”之一更改为其他名称。 Of course all reference to it must also be updated.
当然,对它的所有引用也必须更新。 This is an ambiguity error.
这是一个歧义错误。
This is an old question but i will answer anyway, maybe will help someone. 这是一个老问题,但是我还是会回答,也许会帮助别人。
Change de version of ExpandableLayout to: 将ExpandableLayout的版本更改为:
compile 'com.github.traex.expandablelayout:library:1.3'
Than you will have other issues: 比起您还有其他问题:
Error:(16) No resource identifier found for attribute 'contentLayout' in package ....
change: 更改:
contentLayout ---> el_contentLayout
headerLayout ---> el_headerLayout
if you call the contentLayout or header layout in JAVA, change: 如果您在JAVA中调用contentLayout或标头布局,请更改:
getHeaderRelativeLayout() ----> getHeaderLayout()
getContentRelativeLayout() ----> getContentLayout()
and everything will work just fine :) 一切都会很好:)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.