简体   繁体   中英

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:

"headerLayout" has already been defined

I tried to find which library use this from my library list and maybe this one: 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 ...

...debug\\values\\values.xml:440: error: Attribute "headerLayout" has already been defined

And this is the 440. line:

<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:

<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.

Edit:

A workaround would be to change one of the name "headerLayout" to something else. 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:

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:

getHeaderRelativeLayout()  ---->  getHeaderLayout()
getContentRelativeLayout() ---->  getContentLayout()

and everything will work just fine :)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM