Android appcompat_v7:检索项目的父项时出错:找不到与给定名称匹配的资源
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/23231174/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
appcompat_v7: Error retrieving parent for item: No resource found that matches the given name
提问by ??? ?
I am trying to build the Android project that uses appcompat_v7 library.
我正在尝试构建使用 appcompat_v7 库的 Android 项目。
For that, I created my project through Eclipse -> New Android Sample Project and added my custom styles.xml and then added the appcompat_v7 library Project -> Properties -> Android -> Add.
为此,我通过 Eclipse -> New Android Sample Project 创建了我的项目并添加了我的自定义 styles.xml,然后添加了 appcompat_v7 库项目 -> 属性 -> Android -> 添加。
But I am getting the following errors in appcompat_v7/res/values/styles_base.xml when I compile my project:
但是当我编译我的项目时,我在 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'.
In my manifest I have declared 14 as my minSdkVersion and 19 as targetSdkVersion:
在我的清单中,我将 14 声明为 minSdkVersion,将 19 声明为 targetSdkVersion:
AndroidManifest.xml:
AndroidManifest.xml:
<uses-sdk
android:minSdkVersion="14"
android:targetSdkVersion="19" />
What can I do to fix these errors and build my project?
我该怎么做才能修复这些错误并构建我的项目?
回答by RamKr
Check Build Target of your project and appcompat_v7 library project. They should be same, if your project has lesser Build Target than you get this error and won't be able to build.
检查项目的 Build Target 和 appcompat_v7 库项目。它们应该是相同的,如果您的项目的 Build Target 少于您收到此错误并且将无法构建。
To fix the problem in Eclipse go to Project->Properties->Android (Project Build Target) and select equal to your appcompat library project.
要解决 Eclipse 中的问题,请转到 Project->Properties->Android (Project Build Target) 并选择等于您的 appcompat 库项目。
回答by Jakub Czaplicki
- Right Click on the supporting library;
- Click on Properties;
- On the left side click on "Android";
- Select the right "Android 5.0 - API 21" and click OK;
- Clean the support library: Project -> Clean;
- 右键单击支持的库;
- 点击属性;
- 在左侧点击“Android”;
- 选择右边的“Android 5.0 - API 21”,点击确定;
- 清理支持库:项目 -> 清理;
Repeat the above steps for your project.
对您的项目重复上述步骤。
回答by hfmanson
When using the the appcompat_v7 library the targetSdkVersion should be the same number as the major Android Support Library version number. E.g. on my SDK installation the version number is 23.0.1 and so my targetSdkVersion should be 23 (Android 6.0)
使用 appcompat_v7 库时,targetSdkVersion 应与主要 Android 支持库版本号相同。例如,在我的 SDK 安装中,版本号是 23.0.1,所以我的 targetSdkVersion 应该是 23 (Android 6.0)
回答by Eric
I just ran into a similar issue when upgrading appcompat-v7 from 22.2.0 23.1.0. Updating compileSdkVersion to 23 fixed it.
我刚从 22.2.0 23.1.0 升级 appcompat-v7 时遇到了类似的问题。将 compileSdkVersion 更新到 23 修复了它。
回答by Gene
Try this: https://www.youtube.com/watch?v=HpXoCfoX_QY
试试这个:https: //www.youtube.com/watch?v=HpXoCfoX_QY
Also, make sure your "appcompat_v7" library is open and you see the folders.
另外,请确保您的“appcompat_v7”库已打开并且您可以看到文件夹。
回答by Ahmad Pourbafrani
Check if Android Support Library and Android SDK Build-tools and Android SDK Platform-tools are updated. I updated Android Support Library and not Build-tools and this error appeared. After updating Build-tools it solved.
检查 Android Support Library 和 Android SDK Build-tools 和 Android SDK Platform-tools 是否更新。我更新了 Android 支持库而不是 Build-tools,出现了这个错误。更新构建工具后,它解决了。