在Android Studio中添加全屏活动后构建错误

Dmi*_*kiy 10 android android-studio

我正在尝试在Android Studio中使用我的第一个"Hello World"类应用程序.我尝试添加一个新活动(首先通过New - > Android Component,不喜欢结果,删除它,然后通过New - > Activity - >选择Fullscreen活动).现在我收到这些错误:

  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
Run Code Online (Sandbox Code Playgroud)

我试过在我的项目中搜索buttonBarStyle.它被发现在:

  • 构建文件夹(我想我应该忽略它,不应该吗?)
  • 新活动的布局文件(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. -->
Run Code Online (Sandbox Code Playgroud)

因此,旧的Androids似乎需要这些属性,但我想在API 11声明的属性和这些手动属性之间存在某种冲突.我应该怎么解决它们?

Ser*_*kyi 25

这是因为com.android.support:appcompat-v7:18.0.0已经有了这个属性.因此,如果您计划使用此支持库(并且您应该),则可以安全地从项目中删除此属性的声明\src\main\res\values\attrs.xml.我想,这个重复是因为AndroidStudio新的活动向导,并不认为你可以使用支持库,所以它自己生成所有代码.