[英]Error retrieving parent for item: No resource found that matches the given name '@android:style/Theme.AppCompat.Light.DarkActionBar'
[英]Theme.AppCompat.Light.DarkActionBar - No resource found
如何正确使用Android支持库,因为我的清单文件中有此错误:
android:theme="@style/Theme.AppCompat.Light.DarkActionBar"
error: Error: No resource found that matches the given name
(at 'theme' with value '@style/Theme.AppCompat.Light.DarkActionBar').
AndroidManifest.xml /ttab line 39 Android AAPT Problem
我的朋友之前在其他计算机上为我实现了此功能,现在我必须单独执行此操作。 请帮我:)
我正在使用ADT
我的styles.xml:
<resources>
<!--
Base application theme, dependent on API level. This theme is replaced
by AppBaseTheme from res/values-vXX/styles.xml on newer devices.
-->
<style name="AppBaseTheme" parent="android:Theme.Light">
<!--
Theme customizations available in newer API levels can go in
res/values-vXX/styles.xml, while customizations related to
backward-compatibility can go here.
-->
</style>
<!-- Application theme. -->
<style name="AppTheme" parent="AppBaseTheme">
<!-- All customizations that are NOT specific to a particular API-level can go here. -->
</style>
<style name="Theme.AppCompat.Light">
<!-- theme customizations here. -->
</style>
<style name="Theme.AppCompat.Light.DarkActionBar" parent="Theme.AppCompat.Light">
<!-- theme customizations here. -->
</style>
</resources>
在“android-support-v7-appcompat”项目中:
另一方面,使用“android-support-v7-appcompat”的项目:
如果您使用的是Gradle,则说明最新版本的兼容性库存在问题。
如果build.gradle
文件中包含以下内容, build.gradle
末尾带有'+'
:
dependencies {
compile 'com.android.support:appcompat-v7:+'
}
然后它可能会抓住你想要的更高版本的库。
将依赖项更改为:
dependencies {
compile 'com.android.support:appcompat-v7:18.0+'
}
可以解决你的问题。
你能试试吗?
android:theme="Theme.AppCompat.Light.DarkActionBar"
代替
android:theme="@style/Theme.AppCompat.Light.DarkActionBar"
在您的应用程序依赖项文件中检查您是否具有依赖项
compile 'com.android.support:appcompatv[anything here]
要么
implement 'com.android.support:appcompat[anything here]
删除或注释掉它们,单击“灯泡”以获取自动建议,然后选择添加库依赖项。 单击appcompat的autofillbulb
滚动第一个appcompat版本的选项。 该库将添加到依赖项列表下方。 重建应用程序或使缓存无效并重新启动
在一种情况下,这没有用,并且转到包含项目的文件夹,删除.gradle文件并重新启动Android Studio已经有效。 来自Sneh Pandya在https://reformatcode.com/code/android/error-while-gradle-sync中的回答
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.