0
votes

I'm trying to add appcompat-v7 to my projct, however when I run gradle sync throws the following error:

/path/app/build/intermediates/exploded-aar/com.android.support/appcompat-v7/22.2.1/res/values/values.xml Error:(2) Attribute "layout" has already been defined

That is my build.gradle where I just add the line compile 'com.android.support:appcompat-v7:22.2.1'

/path/app/build/intermediates/exploded-aar/com.android.support/appcompat-v7/22.2.1/res/values/values.xml
Error:(2) Attribute "layout" has already been defined

    compileSdkVersion 22
    buildToolsVersion "22.0.1"

defaultConfig {
    minSdkVersion 14
    targetSdkVersion 22
}
...
dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:support-v4:22.2.1'
    compile 'com.android.support:appcompat-v7:22.2.1'
    compile 'com.google.android.gms:play-services-analytics:7.3.0'
    compile('org.simpleframework:simple-xml:2.7.1') {
        exclude group: 'stax', module: 'stax-api'
        exclude group: 'xpp3', module: 'xpp3'
    }
    compile('com.crashlytics.sdk.android:crashlytics:2.5.1@aar') {
        transitive = true;
    }
}
2

2 Answers

0
votes

It's likely that either your project or one of your dependencies defines a 'layout' attribute. In my experience, when this occurs the gradle output contains information that will lead you to where the duplicate attribute is defined. You can then often use this information to track down and rename the conflicting attribute. If you paste your full output from gradle it can help us pinpoint the exact cause.

0
votes

The log really describes the problem, I found the following code snippet on file res/values/attr.xml

<declare-styleable name="CustomListView">
    <attr name="layout" format="integer"/>
</declare-styleable>

I commented the code and Bingo!