android - 切换到 ActionBarCompat,但出现与主题相关的构建错误

标签 android actionbarsherlock gradle android-actionbar-compat

我正在尝试将 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'.

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

最佳答案

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

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

我不知道为什么我会这么宣布。可能是一些复制粘贴代码。但这是问题的根源。

我的 ActionBarCompat 现在运行良好。顺便说一句,ActionBarSherlock 与上述声明完美配合。

关于android - 切换到 ActionBarCompat,但出现与主题相关的构建错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18299450/

相关文章:

android - fragment 选项卡中的框架布局

android - 怎样才能让ActionBar上的item为左一中右一?

gradle - 使用 Kotlin DSL 进行集成测试的单独 Gradle 源集

groovy - 为什么两次访问Groovy进程的getText()都会导致失败?

gradle - Gradle:调用jar任务

Android 以编程方式获取应用程序的所有受支持的深层链接

Android DialogFragment : How to preserve view in multiple show() invocation?

android - 删除操作栏上的额外图标(使用 ShareActionProvider 和 ActionBarSherlock 时)

Android ProgressBar Indeterminate 未正确调整大小

android - 使用 Facebook Android SDK 在没有打开对话框的情况下发布附件?