38

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?

Captain H.
  • 538
  • 1
  • 5
  • 13

2 Answers2

73

You should remove this line in your dependencies :

compile 'com.android.support:appcompat-v7:18.0.0'
Guerwan
  • 766
  • 6
  • 4
  • 2
    Thanks, I have no idea why I put both ABS and AppCompat. – Captain H. Sep 12 '13 at 18:05
  • 3
    You checked the 'Action Bar' checkbox in the 'New Project' wizzard – passsy Oct 04 '13 at 14:43
  • Thanks, I got a truly maddening "Attribute "color" has already been defined" for a line unrelated to color in any way (or so it seems), and this fixed it. – Atorian Nov 01 '14 at 21:39
  • how this has anything to do with color or text attribute? ;( – Ewoks Sep 01 '15 at 12:31
  • when i add compile 'com.android.support:design:23.0.1' in gradle file am getting rippleColor alredy defined in materialDialogs values.xml but when i check its not found please help me – Harsha Oct 01 '15 at 09:43
  • @CaptainH. struggling with same issue for 2 hours, what do you mean by ABS here? – Shirish Herwade Sep 13 '16 at 11:43
32

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'
pedroca
  • 1,748
  • 1
  • 19
  • 17
  • This was the exact reason I was getting this error. The gradle output didn't even mention which files were involved in the conflict. Changing the GPS version fixed it. – black Oct 08 '15 at 05:29
  • Thank you for your knowledge. Is '7.0.0' the last one which can use ABS or do I have to try '6.5.87'? – Wooseong Kim Mar 08 '16 at 14:11
  • I'm not completely sure what is the last one but 7.0.0 and oldest versions should work, although I recommend you to use the last version of play services with AppCompat only. – pedroca Mar 08 '16 at 23:27