【发布时间】:2013-10-28 10:17:45
【问题描述】:
我正在 Android Studio 中试验我的第一个类似“Hello World”的应用程序。我尝试添加一个新活动(首先通过新建 -> Android 组件,不喜欢结果,将其删除,然后通过新建 -> 活动 -> 选择的全屏活动)。现在我收到这些错误:
Gradle: Execution failed for task ':LanguagesMemorizer:processDebugResources'.
> Could not call IncrementalTask.taskAction() on task ':LanguagesMemorizer:processDebugResources'
C:\...\src\main\res\values\attrs.xml
Gradle: Attribute "buttonBarStyle" has already been defined
Gradle: Attribute "buttonBarButtonStyle" has already been defined
我尝试在我的项目中搜索 buttonBarStyle。发现于:
- build 文件夹(我想我应该忽略它,不是吗?)
- 新活动的布局文件 (style="?buttonBarStyle")
- values\attrs.xml 本身 (
<declare-styleable ...> <attr name="buttonBarStyle" format="reference" /> ...) - values\styles.xml (
<style...>... <item name="buttonBarStyle">@style/ButtonBar</item>...) - values-v11\styles.xml (
<style...>...<item name="buttonBarStyle">?android:attr/buttonBarStyle</item>...)
所有这些都是自动生成的。我应该如何解决这个错误?
更新:attrs.xml 中有一条注释说
<!-- Declare custom theme attributes that allow changing which styles are
used for button bars depending on the API level.
?android:attr/buttonBarStyle is new as of API 11 so this is
necessary to support previous API levels. -->
所以旧的 Android 似乎需要这些属性,但我猜 API 11 声明的属性和这些手动属性之间存在某种冲突。我应该如何修复它们?
【问题讨论】: