添加 appcompat-v7 api 级别 22 时出错
Error on adding appcompat-v7 api level 22
我正在尝试将 appcompat-v7 添加到我的项目中,但是当我 运行 gradle 同步时抛出以下错误:
/path/app/build/intermediates/exploded-aar/com.android.support/appcompat-v7/22.2.1/res/values/values.xml
错误:(2) 属性 "layout" 已被定义
那是我的 build.gradle,我只是在其中添加了行 compile 'com.android.support:appcompat-v7:22.2.1'
/path/app/build/intermediates/exploded-aar/com.android.support/appcompat-v7/22.2.1/res/values/values.xml
Error:(2) Attribute "layout" has already been defined
compileSdkVersion 22
buildToolsVersion "22.0.1"
defaultConfig {
minSdkVersion 14
targetSdkVersion 22
}
...
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:support-v4:22.2.1'
compile 'com.android.support:appcompat-v7:22.2.1'
compile 'com.google.android.gms:play-services-analytics:7.3.0'
compile('org.simpleframework:simple-xml:2.7.1') {
exclude group: 'stax', module: 'stax-api'
exclude group: 'xpp3', module: 'xpp3'
}
compile('com.crashlytics.sdk.android:crashlytics:2.5.1@aar') {
transitive = true;
}
}
您的项目或您的某个依赖项可能定义了 'layout' 属性。根据我的经验,发生这种情况时,gradle 输出包含的信息将引导您找到重复属性的定义位置。然后,您可以经常使用此信息来追踪和重命名冲突的属性。如果您粘贴 gradle 的完整输出,它可以帮助我们查明确切原因。
日志确实描述了问题,我在文件中找到了以下代码片段res/values/attr.xml
<declare-styleable name="CustomListView">
<attr name="layout" format="integer"/>
</declare-styleable>
我评论了代码和宾果游戏!
我正在尝试将 appcompat-v7 添加到我的项目中,但是当我 运行 gradle 同步时抛出以下错误:
/path/app/build/intermediates/exploded-aar/com.android.support/appcompat-v7/22.2.1/res/values/values.xml 错误:(2) 属性 "layout" 已被定义
那是我的 build.gradle,我只是在其中添加了行 compile 'com.android.support:appcompat-v7:22.2.1'
/path/app/build/intermediates/exploded-aar/com.android.support/appcompat-v7/22.2.1/res/values/values.xml
Error:(2) Attribute "layout" has already been defined
compileSdkVersion 22
buildToolsVersion "22.0.1"
defaultConfig {
minSdkVersion 14
targetSdkVersion 22
}
...
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:support-v4:22.2.1'
compile 'com.android.support:appcompat-v7:22.2.1'
compile 'com.google.android.gms:play-services-analytics:7.3.0'
compile('org.simpleframework:simple-xml:2.7.1') {
exclude group: 'stax', module: 'stax-api'
exclude group: 'xpp3', module: 'xpp3'
}
compile('com.crashlytics.sdk.android:crashlytics:2.5.1@aar') {
transitive = true;
}
}
您的项目或您的某个依赖项可能定义了 'layout' 属性。根据我的经验,发生这种情况时,gradle 输出包含的信息将引导您找到重复属性的定义位置。然后,您可以经常使用此信息来追踪和重命名冲突的属性。如果您粘贴 gradle 的完整输出,它可以帮助我们查明确切原因。
日志确实描述了问题,我在文件中找到了以下代码片段res/values/attr.xml
<declare-styleable name="CustomListView">
<attr name="layout" format="integer"/>
</declare-styleable>
我评论了代码和宾果游戏!