eclipse 检索项目的父项时出错:找不到与给定名称“Theme.AppCompat.Light”匹配的资源
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/27936287/
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
Error retrieving parent for item: No resource found that matches the given name 'Theme.AppCompat.Light'
提问by Steve
I am getting this error in styles.xml:
我在style.xml 中收到此错误:
error: Error retrieving parent for item: No resource found that matches the given name 'Theme.AppCompat.Light'.
错误:检索项目的父项时出错:找不到与给定名称“Theme.AppCompat.Light”匹配的资源。
<style name="AppTheme" parent="AppBaseTheme"></style>
<style name="AppBaseTheme" parent="Theme.AppCompat.Light"> --->Error line
<item name="colorPrimary">@color/holo_orange</item>
<item name="colorPrimaryDark">@color/holo_orange_dark</item>
</style>
Then right click on the project->properties ->Android
然后右键项目->属性->Android
Then my manifest:
然后我的清单:
<uses-sdk
android:minSdkVersion="16"
android:targetSdkVersion="21" />
.......
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppBaseTheme" >
......
</application>
Order and Export:
订购和出口:
I am sure I had updated my sdk to the latest version 21 in Build tools,platform tools,Extras,etc.. I didn't know why this error still occurred.I tried restarting my eclipse and cleaning the project.Still it occurs.
我确定我已经在构建工具、平台工具、Extras 等中将我的 sdk 更新到最新版本 21。我不知道为什么这个错误仍然发生。我尝试重新启动我的 eclipse 并清理项目。仍然发生。
采纳答案by Steve
User ρяσ?ρ?я K comment helped me to solve this error.He told me to add the Appcompat library
in my project.
用户 ρяσ?ρ?я K 评论帮助我解决了这个错误。他告诉我Appcompat library
在我的项目中添加。
For more description:Can't Find Theme.AppCompat.Light for New Android ActionBar Support
有关更多描述:无法找到 Theme.AppCompat.Light 以获取新的 Android ActionBar 支持
All credits goes to User ρяσ?ρ?я.
所有功劳归于用户 ρяσ?ρ?я。
回答by Daniel Persson
As said in comment. You need to add the appcompat to your project in order to get this theme.
正如评论中所说。您需要将 appcompat 添加到您的项目中才能获得此主题。
https://developer.android.com/training/material/compatibility.html
https://developer.android.com/training/material/compatibility.html
To add a support library in eclipse
在 Eclipse 中添加支持库
https://developer.android.com/tools/support-library/setup.html
https://developer.android.com/tools/support-library/setup.html
Adding libraries with resources
添加带有资源的库
To add a Support Library with resources (such as v7 appcompat for action bar) to your application project:
将带有资源的支持库(例如 v7 appcompat for action bar)添加到您的应用程序项目:
Using Eclipse
使用 Eclipse
Create a library project based on the support library code:
根据支持库代码创建一个库项目:
Make sure you have downloaded the Android Support Library using the SDK Manager.
确保您已使用 SDK 管理器下载了 Android 支持库。
Create a library project and ensure the required JAR files are included in the project's build path: Select File > Import. Select Existing Android Code Into Workspace and click Next.
创建一个库项目并确保所需的 JAR 文件包含在项目的构建路径中:选择 File > Import。选择 Existing Android Code Into Workspace 并单击 Next。
Browse to the SDK installation directory and then to the Support Library folder. For example, if you are adding the appcompat project, browse to /extras/android/support/v7/appcompat/.
浏览到 SDK 安装目录,然后浏览到 Support Library 文件夹。例如,如果您要添加 appcompat 项目,请浏览至 /extras/android/support/v7/appcompat/。
Click Finish to import the project. For the v7 appcompat project, you should now see a new project titled android-support-v7-appcompat.
单击完成以导入项目。对于 v7 appcompat 项目,您现在应该会看到一个名为 android-support-v7-appcompat 的新项目。
In the new library project, expand the libs/ folder, right-click each .jar file and select Build Path > Add to Build Path. For example, when creating the the v7 appcompat project, add both the android-support-v4.jar and android-support-v7-appcompat.jar files to the build path.
在新的库项目中,展开 libs/ 文件夹,右键单击每个 .jar 文件并选择 Build Path > Add to Build Path。例如,在创建 v7 appcompat 项目时,将 android-support-v4.jar 和 android-support-v7-appcompat.jar 文件添加到构建路径中。
Right-click the library project folder and select Build Path > Configure Build Path.
右键单击库项目文件夹并选择构建路径 > 配置构建路径。
In the Order and Export tab, check the .jar files you just added to the build path, so they are available to projects that depend on this library project. For example, the appcompat project requires you to export both the android-support-v4.jar and android-support-v7-appcompat.jar files.
在 Order and Export 选项卡中,检查您刚刚添加到构建路径的 .jar 文件,以便它们可用于依赖于该库项目的项目。例如,appcompat 项目要求您导出 android-support-v4.jar 和 android-support-v7-appcompat.jar 文件。
Uncheck Android Dependencies. Click OK to complete the changes. You now have a library project for your selected Support Library that you can use with one or more application projects.
取消选中 Android 依赖项。单击确定以完成更改。您现在拥有了一个用于所选支持库的库项目,您可以将其与一个或多个应用程序项目一起使用。
Add the library to your application project:
将库添加到您的应用程序项目:
In the Project Explorer, right-click your project and select Properties. In the category panel on the left side of the dialog, select Android. In the Library pane, click the Add button.
在 Project Explorer 中,右键单击您的项目并选择 Properties。在对话框左侧的类别面板中,选择 Android。在库窗格中,单击添加按钮。
Select the library project and click OK. For example, the appcompat project should be listed as android-support-v7-appcompat.
选择库项目并单击确定。例如,appcompat 项目应列为 android-support-v7-appcompat。
In the properties window, click OK.
在属性窗口中,单击确定。