Android工作室:Gradle:属性...已经定义错误
Posted
技术标签:
【中文标题】Android工作室:Gradle:属性...已经定义错误【英文标题】:Android studio : Gradle : Attribute ... has already been defined error 【发布时间】:2015-08-29 00:32:57 【问题描述】:我正在从 eclipse-ADT 迁移到 android Studio,并在构建时遇到此错误:-
AGPBI: "kind":"ERROR","text":"Attribute \"track\" has already been defined","sourcePath":"C:\\densie\\project\\src\\main\\res\\values\\colors.xml","position":"startLine":1,"original":""
FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':keyOff:processDebugResources'.
> com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Users\180336\AppData\Local\Android\sdk\build-tools\22.0.1\aapt.exe'' finished with non-zero exit value 1
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
Total time: 6.782 secs
colors.xml 就像:-
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="clicked">#7700ccff</color>
<color name="red">#ffff0000</color>
<color name="dark">#ff303030</color>
<color name="white">#ffffffff</color>
<color name="color_cyan_0">#ff86B6aD</color>
<color name="black">#ff000000</color>
<color name="grey">#ff808080</color>
<color name="menu_grey">#ff888888</color>
<color name="light_grey">#ffcccccc</color>
<color name="dark_white">#ffdddddd</color>
<color name="active_guest">#7777ff</color>
<color name="light_green">#33aa99</color>
<color name="ttms_green">#00fcfc</color>
其中没有“track”属性。
请帮助。我已经花了很多时间在谷歌上搜索它或查看论坛,这真的很令人沮丧。
【问题讨论】:
【参考方案1】:请删除 compile 'com.android.support:appcompat-v7:22.2.0'
(可能你的版本不同)从 app/build.gradle 文件中的依赖项中删除。然后 *Tools>Android>Sync with Gradle files*
。和*Build>Clean Project & Rebuild*
。
更多:
【讨论】:
以上是关于Android工作室:Gradle:属性...已经定义错误的主要内容,如果未能解决你的问题,请参考以下文章
Android Gradle 的依赖缓存可能已损坏且 gradle build 无法正常工作
Android Gradle 插件Gradle 扩展属性 ① ( Gradle 扩展属性简介 | Gradle 自定义 task 任务示例 )
Android Gradle 插件Gradle 扩展属性 ① ( Gradle 扩展属性简介 | Gradle 自定义 task 任务示例 )