【问题标题】:Gradle error "Attribute "xxx" has already been defined" in Android StudioAndroid Studio 中的 Gradle 错误“属性“xxx”已被定义”
【发布时间】:2013-09-15 18:00:03
【问题描述】:

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

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 控制台的功能不如 Eclipse 的控制台,所以我不知道问题的根源。 有人知道导致这些编译错误的原因吗?

【问题讨论】:

    标签: android maven gradle android-studio maven-central


    【解决方案1】:

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

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

    【讨论】:

    • 谢谢,我不知道为什么我把 ABS 和 AppCompat 都放了。
    • 您在“新建项目”向导中选中了“操作栏”复选框
    • 谢谢,我得到了一个真正令人抓狂的“属性“颜色”已经被定义”,它以任何方式(或者看起来)与颜色无关,并且修复了它。
    • 这与颜色或文本属性有什么关系? ;(
    • 当我在 gradle 文件中添加 compile 'com.android.support:design:23.0.1' 时,rippleColor 已经在 materialDialogs values.xml 中定义,但是当我检查它时找不到请帮助我跨度>
    【解决方案2】:

    Google Play 服务的最新版本现在使用 appcompat-v7,因此您不能将它与 actionbarsherlock 一起使用。您只能使用 appcompat-v7 或之前版本的播放服务:

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

    【讨论】:

    • 这是我收到此错误的确切原因。 gradle 输出甚至没有提到冲突涉及哪些文件。更改 GPS 版本修复了它。
    • 感谢您的知识。 '7.0.0' 是最后一个可以使用 ABS 的还是我必须尝试 '6.5.87'?
    • 我不完全确定最后一个是什么,但 7.0.0 和最旧的版本应该可以工作,尽管我建议你只使用 AppCompat 的最后一个版本的播放服务。
    猜你喜欢
    • 1970-01-01
    • 2015-09-19
    • 1970-01-01
    • 1970-01-01
    • 2015-08-29
    • 1970-01-01
    • 1970-01-01
    • 2014-12-20
    • 2016-09-14
    相关资源
    最近更新 更多