切换到ActionBarCompat后,出现与主题相关的构建错误。

6

我正在尝试将ActionBarCompat集成到我的一个项目中。我使用Gradle构建系统。

我已经添加了以下依赖项:

dependencies {
    compile 'com.android.support:appcompat-v7:18.0.+'
}

我没有使用自定义样式,而是在我的AndroidManifest.xml文件中设置了主题:

    <application
        android:icon="@drawable/icon"
        android:label="@string/app_name"
        android:theme="@style/Theme.AppCompat" >

问题是这在一个Android库项目中。它与ActionBarSherlock很好地配合工作。但现在我遇到以下错误。

LibraryProject/build/res/all/release/values/values.xml:764: error: Error: No resource found that matches the given name: attr 'dropdownListPreferredItemHeight'.
LibraryProject/build/res/all/release/values/values.xml:768: error: Error: No resource found that matches the given name: attr 'popupMenuStyle'.
LibraryProject/build/res/all/release/values/values.xml:813: error: Error: No resource found that matches the given name: attr 'dropdownListPreferredItemHeight'.
LibraryProject/build/res/all/release/values/values.xml:817: error: Error: No resource found that matches the given name: attr 'popupMenuStyle'.
LibraryProject/build/res/all/release/values/values.xml:848: error: Error: No resource found that matches the given name: attr 'dropdownListPreferredItemHeight'.
LibraryProject/build/res/all/release/values/values.xml:852: error: Error: No resource found that matches the given name: attr 'popupMenuStyle'.
LibraryProject/build/res/all/release/values/values.xml:912: error: Error: No resource found that matches the given name: attr 'actionDropDownStyle'.
LibraryProject/build/res/all/release/values/values.xml:925: error: Error: No resource found that matches the given name: attr 'listChoiceBackgroundIndicator'.
LibraryProject/build/res/all/release/values/values.xml:923: error: Error: No resource found that matches the given name: attr 'panelMenuListTheme'.
LibraryProject/build/res/all/release/values/values.xml:922: error: Error: No resource found that matches the given name: attr 'panelMenuListWidth'.
LibraryProject/build/res/all/release/values/values.xml:969: error: Error: No resource found that matches the given name: attr 'actionDropDownStyle'.
LibraryProject/build/res/all/release/values/values.xml:975: error: Error: No resource found that matches the given name: attr 'listChoiceBackgroundIndicator'.
LibraryProject/build/res/all/release/values/values.xml:973: error: Error: No resource found that matches the given name: attr 'panelMenuListTheme'.
LibraryProject/build/res/all/release/values/values.xml:972: error: Error: No resource found that matches the given name: attr 'panelMenuListWidth'.
LibraryProject/build/res/all/release/values/values.xml:998: error: Error: No resource found that matches the given name: attr 'actionDropDownStyle'.
LibraryProject/build/res/all/release/values/values.xml:1002: error: Error: No resource found that matches the given name: attr 'listChoiceBackgroundIndicator'.

什么可能是问题?有人能提供解决方案吗?

请粘贴完整的 build.gradle 文件。 - Grzegorz Żur
1个回答

11

我终于找到了问题所在!看起来我的attrs.xml文件中有一个多余的声明:

    <declare-styleable name="Theme">
    </declare-styleable>

我不知道为什么会声明那个东西,可能是复制粘贴的代码。但那就是问题的根源。

现在ActionBarCompat已经完美地工作了。顺便说一下,ActionBarSherlock与上述声明完美地配合使用。


2
我们不应该说谢谢,但是..谢谢你。这个问题花了5个小时。 - VonSchnauzer
我也遇到了这个问题好几个小时,你救了我的一天。我删除了所有的“<declare-styleable name="Theme"></declare-styleable>”,现在它正常工作了。谢谢。 - LucasFM

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接