在Android Studio中,Gradle错误“Attribute”xxx“已被定义”

我在Android Studio中创build了一个项目,并使用Maven Central添加了一些依赖关系,当我尝试编译时,遇到这种types的错误:

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

等等…这是我的build.gradle文件:

 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' } 

令人遗憾的是,Make Console不如Eclipse的控制台,所以我不知道问题的根源。 有没有人有一个什么原因导致这些编译错误的想法?

你应该删除你的依赖关系中的这一行:

 compile 'com.android.support:appcompat-v7:18.0.0' 

Google Play服务的最新版本现在使用appcompat-v7,所以您不能在actionbarsherlock中使用它。 您只能使用appcompat-v7或以前版本的播放服务:

 compile 'com.google.android.gms:play-services:7.0.0'