Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Gradle error "Attribute "xxx" has already been defined" in Android Studio

I created a project in Android Studio and added a few dependencies using Maven Central and when I try to compile, I run into this type of errors:

Error:Gradle: Attribute "titleTextStyle" has already been defined
Error:Gradle: Attribute "subtitleTextStyle" has already been defined
[...]

And so on... Here is my build.gradle file:

buildscript {
    repositories {
    mavenCentral()
    }
    dependencies {
    classpath 'com.android.tools.build:gradle:0.5.+'
    }
}
apply plugin: 'android'

repositories {
    mavenCentral()
}

android {
    compileSdkVersion 18
    buildToolsVersion "17.0.0"

    defaultConfig {
    minSdkVersion 8
    targetSdkVersion 18
    }
}

dependencies {
    // Support Libraries
    compile 'com.android.support:support-v4:18.0.0'
    compile 'com.android.support:appcompat-v7:18.0.0'
    compile 'com.android.support:support-v13:18.0.0'

    // Third-Party Librairies
    compile 'com.actionbarsherlock:actionbarsherlock:4.4.0@aar'
    compile 'ch.acra:acra:4.5.0'

}

Sadly the Make Console doesn't speak as much as Eclipse's Console, so I have no idea of the problem's origin. Does anyone have an idea of what causes these compile errors?

like image 259
Captain H. Avatar asked Sep 11 '13 15:09

Captain H.


2 Answers

You should remove this line in your dependencies :

compile 'com.android.support:appcompat-v7:18.0.0'
like image 95
Guerwan Avatar answered Nov 05 '22 11:11

Guerwan


The last version of Google Play Services now uses appcompat-v7, so u can't use it with actionbarsherlock. You have to use only appcompat-v7 or the previous version of play services:

compile 'com.google.android.gms:play-services:7.0.0'
like image 32
pedroca Avatar answered Nov 05 '22 13:11

pedroca