【问题标题】:appcompat_v7: Error retrieving parent for item: No resource found that matches the given nameappcompat_v7:检索项目的父项时出错:未找到与给定名称匹配的资源
【发布时间】:2014-04-22 22:12:03
【问题描述】:

我正在尝试构建使用 appcompat_v7 库的 Android 项目。

为此,我通过 Eclipse -> New Android Sample Project 创建了我的项目并添加了我的自定义 styles.xml,然后添加了 appcompat_v7 库 Project -> Properties -> Android -> Add。

但是当我编译我的项目时,我在 appcompat_v7/res/values/styles_base.xml 中遇到了以下错误:

appcompat_v7/res/values/styles_base.xml:24: error: Error retrieving parent for item: No resource found that matches the given name 'Widget.AppCompat.Base'.

appcompat_v7/res/values/styles_base.xml:84: error: Error retrieving parent for item: No resource found that matches the given name 'Widget.AppCompat.Base'.

appcompat_v7/res/values/styles_base.xml:166: error: Error retrieving parent for item: No resource found that matches the given name 'Widget.AppCompat.Base'.

appcompat_v7/res/values/styles_base.xml:243: error: Error retrieving parent for item: No resource found that matches the given name 'Widget.AppCompat.Base'.

appcompat_v7/res/values/styles_base.xml:261: error: Error retrieving parent for item: No resource found that matches the given name 'Widget.AppCompat.Base.DropDownItem'.

appcompat_v7/res/values/styles_base.xml:319: error: Error retrieving parent for item: No resource found that matches the given name 'Widget.AppCompat.Base'.

appcompat_v7/res/values/styles_base.xml:323: error: Error retrieving parent for item: No resource found that matches the given name 'Widget.AppCompat.Light.Base'.

appcompat_v7/res/values/styles_base.xml:347: error: Error retrieving parent for item: No resource found that matches the given name 'TextAppearance.AppCompat.Base'.

appcompat_v7/res/values/styles_base.xml:391: error: Error retrieving parent for item: No resource found that matches the given name 'Widget.AppCompat.Base'.

appcompat_v7/res/values/themes_base.xml:189: error: Error retrieving parent for item: No resource found that matches the given name 'Theme.AppCompat.Base'.

在我的清单中,我已将 14 声明为 minSdkVersion,将 19 声明为 targetSdkVersion:

AndroidManifest.xml:

<uses-sdk
        android:minSdkVersion="14"
        android:targetSdkVersion="19" />

我可以做些什么来修复这些错误并构建我的项目?

【问题讨论】:

    标签: android coding-style android-theme android-styles android-appcompat


    【解决方案1】:

    检查项目的构建目标和 appcompat_v7 库项目。它们应该是相同的,如果您的项目的构建目标少于您收到此错误并且无法构建。

    要解决 Eclipse 中的问题,请转到 Project->Properties->Android (Project Build Target) 并选择等于您的 appcompat 库项目。

    【讨论】:

      【解决方案2】:
      1. 右击支持库;
      2. 点击属性;
      3. 在左侧点击“Android”;
      4. 选择右边的“Android 5.0 - API 21”,点击确定;
      5. 清理支持库:项目->清理;

      为您的项目重复上述步骤。

      【讨论】:

        【解决方案3】:

        使用 appcompat_v7 库时,targetSdkVersion 应该与主要的 Android 支持库版本号相同。例如。在我的 SDK 安装中,版本号是 23.0.1,所以我的 targetSdkVersion 应该是 23(Android 6.0)

        【讨论】:

          【解决方案4】:

          从 22.2.0 23.1.0 升级 appcompat-v7 时,我刚刚遇到了类似的问题。将 compileSdkVersion 更新到 23 修复了它。

          【讨论】:

            【解决方案5】:

            试试这个: https://www.youtube.com/watch?v=HpXoCfoX_QY

            另外,请确保您的“appcompat_v7”库已打开并且您可以看到文件夹。

            【讨论】:

              【解决方案6】:

              检查 Android Support Library 和 Android SDK Build-tools 和 Android SDK Platform-tools 是否更新。 我更新了 Android Support Library 而不是 Build-tools 并且出现了这个错误。更新构建工具后它解决了。

              【讨论】:

                猜你喜欢
                • 2017-12-27
                • 1970-01-01
                • 2019-07-02
                • 1970-01-01
                • 2017-10-27
                • 2014-06-04
                相关资源
                最近更新 更多