我正在尝试将 Android Studio 项目中的 appcompat-v7 从 v20.0.0 更新到 21.0.0 以使用材料设计组件,但我总是遇到相同的错误:
“错误:属性“颜色”已被定义”
我不知道如何修复此错误,我在互联网上搜索但无法得到答案。
这是我的等级:
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 的答案后,我的问题得到了解决。如果您查看错误消息中显示的行,您可以准确地确定哪个属性导致了问题。
就我而言,它是一个名为color
在一个习惯中attrs
xml 文件。未使用该自定义视图,因此我只是评论该行并解决了问题。
可能的解决步骤
检查错误输出以查找导致问题的文件路径和行号
通过文件系统资源管理器转到该文件并查找有问题的行
该行应该提到什么(自定义)视图具有已在某处定义的属性。
返回 IDE 中的项目,找到该属性,如果未使用该属性,请注释,否则如果已使用,请更改其名称。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)