错误:属性“颜色"为已经定义,请更新appcompat v-7 [英] Error:Attribute "color" has already been defined, update appcompat v-7

查看:91
本文介绍了错误:属性“颜色"为已经定义,请更新appcompat v-7的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将Android Studio项目中的appcompat-v7从v20.0.0更新为21.0.0以使用材质设计组件,但我始终遇到相同的错误:

I am trying to update my appcompat-v7 in Android Studio project from v20.0.0 to 21.0.0 for use material design component but I allways get the same error:

错误:属性颜色"已经定义"

"Error:Attribute "color" has already been defined"

我不知道该如何解决此错误,我在互联网上进行了搜索,但找不到答案. 这是我的礼物:

I have not idea about what to do for fix this error, I searched in internet but I cant get the answer. Here is my gradle:

android {

    compileOptions.encoding = "iso-8859-1"
    compileSdkVersion 21
    buildToolsVersion "21.1.1"

    defaultConfig {
        applicationId "com.test"
        minSdkVersion 11
        targetSdkVersion 22
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
        }
    }
}

dependencies {

    compile fileTree(dir: 'libs', include: ['*.jar'])
 compile 'com.android.support:support-v4:20.0.0'
    compile 'com.google.http-client:google-http-client-gson:1.19.0'
    compile 'com.google.code.gson:gson:2.2.4'
    compile "com.android.support:appcompat-v7:21.0.+"

}

这是存在冲突的路径

C:\Users\Abel Dominguez\Documents\PROYECTOS_ANDROID\definitivos\d2\app\build\intermediates\exploded-aar\com.android.support\appcompat-v7\21.0.3\res\values\values.xml

这是另一个错误:

Error:Execution failed for task ':app:processDebugResources'.
> com.android.ide.common.internal.LoggedErrorException: Failed to run command:
    C:\Users\Abel Dominguez\AppData\Local\Android\sdk1\build-tools\build-tools-21.1.1\aapt.exe package -f --no-crunch -I C:\Users\Abel Dominguez\AppData\Local\Android\sdk1\platforms\android-21\android.jar -M C:\Users\Abel Dominguez\Documents\PROYECTOS_ANDROID\definitivos\d2\app\build\intermediates\manifests\full\debug\AndroidManifest.xml -S C:\Users\Abel Dominguez\Documents\PROYECTOS_ANDROID\definitivos\d2\app\build\intermediates\res\debug -A C:\Users\Abel Dominguez\Documents\PROYECTOS_ANDROID\definitivos\d2\app\build\intermediates\assets\debug -m -J C:\Users\Abel Dominguez\Documents\PROYECTOS_ANDROID\definitivos\d2\app\build\generated\source\r\debug -F C:\Users\Abel Dominguez\Documents\PROYECTOS_ANDROID\definitivos\d2\app\build\intermediates\res\resources-debug.ap_ --debug-mode --custom-package com.wherefriend -0 apk --output-text-symbols C:\Users\Abel Dominguez\Documents\PROYECTOS_ANDROID\definitivos\d2\app\build\intermediates\symbols\debug
Error Code:
    1
Output:
    C:\Users\Abel Dominguez\Documents\PROYECTOS_ANDROID\definitivos\d2\app\build\intermediates\res\debug\values\values.xml:94: error: Attribute "color" has already been defined

推荐答案

阅读@petey的答案后,我的问题已解决.如果您查看错误消息中显示的行,则可以精确地确定哪个属性引起了问题.

My problem was solved after I read the answer by @petey. If you look at the line displayed in error message you can precisely determine which attribute is causing problem.

就我而言,它是自定义attrs xml文件中名为color的属性.没有使用该自定义视图,所以我只评论了这一行,问题就解决了.

In my case, it was an attribute named color in a custom attrs xml file. That custom view wasn't used so I just commented that line and problem was solved.

可能的解决方法步骤

  1. 检查错误输出以查找导致问题的文件和行号的路径

  1. Check error output to find the path to the file and line number that is causing problems

通过文件系统资源管理器转到该文件,并查找有问题的行

Go to that file through your file system explorer and look for the line in question

该行应提及哪些(自定义)视图具有已在某处定义的属性.

That line should mention what (custom) view has an attribute that is already defined somewhere.

在IDE中的项目中,找到该属性,如果未使用该属性,则进行注释,否则,如果使用,则更改其名称.

Back in the project in you IDE, find that attribute and if it is not used comment, otherwise if it IS used, change it's name.

这篇关于错误:属性“颜色"为已经定义,请更新appcompat v-7的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆