Android 找不到与给定名称“@style/Theme.AppCompat.Light”匹配的资源
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/21059612/
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
No resource found that matches the given name '@style/Theme.AppCompat.Light'
提问by Sauron
I have been on this problem for a couple hours. After downloading a repository from github, the only error in any .xml file is:
我一直在这个问题上几个小时。从 github 下载存储库后,任何 .xml 文件中的唯一错误是:
No resource found that matches the given name '@style/Theme.AppCompat.Light'
The code is very straightforward, but there is not one straightforward answer I have found, on how to alleviate the error.
代码非常简单,但我没有找到一个关于如何减轻错误的直接答案。
here is the code (in file res/values/styles.xml):
这是代码(在文件 res/values/styles.xml 中):
<style name="AppBaseTheme" parent="@style/Theme.AppCompat.Light">
<!-- API 14 theme customizations can go here. -->
</style>
The project is located at: https://github.com/erikswed/InstaChatXI am on Windows, using Eclipse Kepler
该项目位于:https: //github.com/erikswed/InstaChatX我在 Windows 上,使用 Eclipse Kepler
回答by Raghunandan
What are the steps for that? where is AppCompat located?
这样做的步骤是什么?AppCompat 在哪里?
Download the support library here:
在此处下载支持库:
http://developer.android.com/tools/support-library/setup.html
http://developer.android.com/tools/support-library/setup.html
If you are using Eclipse:
如果您使用的是 Eclipse:
Go to the tabs at the top and select ( Windows -> Android SDK Manager ). Under the 'extras' section, check 'Android Support Library' and check it for installation.
转到顶部的选项卡并选择( Windows -> Android SDK Manager )。在“附加”部分下,选中“Android 支持库”并检查安装。
After that, the AppCompat library can be found at:
之后,可以在以下位置找到 AppCompat 库:
android-sdk/extras/android/support/v7/appcompat
You need to reference this AppCompat library in your Android project.
您需要在您的 Android 项目中引用此 AppCompat 库。
Import the library into Eclipse.
将库导入 Eclipse。
- Right click on your Android project.
- Select properties.
- Click 'add...' at the bottom to add a library.
- Select the support library
- Clean and rebuild your project.
- 右键单击您的 Android 项目。
- 选择属性。
- 单击底部的“添加...”以添加库。
- 选择支持库
- 清理并重建您的项目。
回答by Vins
If you are looking for the solution in Android Studio:
如果您正在Android Studio中寻找解决方案:
- Right clickon your app
- Open Module Settings
- Select Dependenciestab
- Click on green +symbol which is on the right side
- Select Library Dependency
- Choose appcompat-v7from list
- 右键单击您的应用
- 打开模块设置
- 选择依赖项选项卡
- 单击右侧的绿色+符号
- 选择库依赖
- 从列表中选择appcompat-v7
回答by Mick Byrne
The steps described above do work, however I've encountered this problem on IntelliJ IDEA and have found that I'm having these problems with existing projects and the only solution is to remove the 'appcompat' module (not the library) and re-import it.
上述步骤确实有效,但是我在 IntelliJ IDEA 上遇到了这个问题,并且发现我在现有项目中遇到了这些问题,唯一的解决方案是删除“appcompat”模块(而不是库)并重新 -导入它。
回答by Summved Jain
Below are the steps you can try it out to resolve the issue: -
以下是您可以尝试解决问题的步骤:-
- Provide reference of AppCompat Library into your project.
- If option 1 doesn't solve the issue then you can try to change the style.xml file to below code.
- 在您的项目中提供 AppCompat 库的参考。
- 如果选项 1 不能解决问题,那么您可以尝试将 style.xml 文件更改为以下代码。
parent="android:Theme.Holo.Light"
instead.
反而。
parent="android:Theme.AppCompat.Light"
But option 2 will require minimum sdk version 14.
但是选项 2 将需要最低 sdk 版本 14。
Hope this will help !
希望这会有所帮助!
Summved
总和