Android 找不到资源 - Theme.AppCompat.Light.DarkActionBar

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/21900853/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-20 05:17:02  来源:igfitidea点击:

No resource found - Theme.AppCompat.Light.DarkActionBar

androidandroid-actionbar-compat

提问by Sun

I used ActionBar Style Generator, and now trying to use into my app, but getting :

我使用了 ActionBar 样式生成器,现在尝试在我的应用程序中使用,但得到:

error: Error retrieving parent for item: No resource found that matches the given name '@style/ Theme.AppCompat.Light.DarkActionBar'.

错误:检索项目的父项时出错:找不到与给定名称“@style/Theme.AppCompat.Light.DarkActionBar”匹配的资源。

i am using android-support-v7-appcompat.jarlib inside libs folder

我在 libs 文件夹中使用android-support-v7-appcompat.jarlib

my target is to make my app compatible 2.3 or above

我的目标是让我的应用兼容 2.3 或更高版本

采纳答案by Raghunandan

AppCompatis a library project. You need to reference the library project in your android project.

AppCompat是一个图书馆项目。您需要在您的 android 项目中引用库项目。

Check the topic Adding libraries with resources.

检查主题添加带有资源的库

回答by M D

If you're using Eclipse, then add the reference libraryinto your project as the following steps:

如果您使用的是Eclipsereference library请按照以下步骤将Eclipse添加到您的项目中:

  1. Right-click your project in the Project ExplorerView.
  2. Click Properties.
  3. Click Androidin the Propertieswindow.
  4. In the Librarygroup, click Add...
    • See the image below.
  5. Select the library. ClickOK.
  6. Click the OKbutton again in the Properties window.
  1. Project Explorer视图中右键单击您的项目。
  2. 单击Properties
  3. AndroidProperties窗口中单击。
  4. Library组中,单击Add...
    • 见下图。
  5. 选择库。单击OK
  6. OK在“属性”窗口中再次单击该按钮。

The "Add" button in the project Properties window, Android section, Library group.

项目属性窗口中的“添加”按钮,Android 部分,库组。

回答by N J

If you are using Android Studiothen just add the dependency

如果您使用的是Android Studio,则只需添加依赖项

dependencies {
     implementation 'com.android.support:appcompat-v7:25.0.1'
}

to app/build.gradle. And that will work

app/build.gradle。这会起作用

回答by James Joyce

For anyone out there using VS2015, I was getting this error too, and it turns out I hadn't added the library to the project...

对于任何使用 VS2015 的人,我也遇到了这个错误,结果我没有将库添加到项目中......

Install-Package Xamarin.Android.Support.v7.AppCompat

回答by Prakash

If you are using Eclipse just copying android-support-v7-appcompat.jar to libs folder will not work if you are going to use resources.

如果您正在使用 Eclipse,如果您打算使用资源,则仅将 android-support-v7-appcompat.jar 复制到 libs 文件夹将不起作用。

Follow steps from here for "Adding libraries with resources".

按照此处的“添加带有资源的库”的步骤操作。

回答by Wladimir Koroy

A simple solution - replace contents this file (/res/values/styles.xml) to this is text:

一个简单的解决方案 - 将此文件(/res/values/styles.xml)的内容替换为文本:

<resources>

<!-- Base application theme. -->
<style name="AppTheme" parent="android:Theme.Holo.Light.DarkActionBar">
    <!-- Customize your theme here. -->
</style>

回答by Sreenu Yatam

dependencies {

    compile 'com.android.support:appcompat-v7:23.0.0'

}

This worked for me... in Android Studio...

这对我有用......在Android Studio中......

回答by JanB

In my case, I took an androidproject from one computer to another and had this problem. What worked for me was a combination of some of the answers I've seen:

就我而言,我将一个android项目从一台计算机转移到另一台计算机并遇到了这个问题。对我有用的是我看到的一些答案的组合:

  • Remove the copy of the appcompat library that was in the libs folder of the workspace
  • Install sdk 21
  • Change the project properties to use that sdk build enter image description here
  • Set up and start an emulator compatible with sdks 21
  • Update the Run Configuration to prompt for device to run on & choose Run
  • 删除工作区的 libs 文件夹中的 appcompat 库的副本
  • 安装 SDK 21
  • 更改项目属性以使用该 sdk 构建 在此处输入图片说明
  • 设置并启动与 sdks 21 兼容的模拟器
  • 更新运行配置以提示设备运行并选择运行

Mine ran fine after these steps.

经过这些步骤,我的运行良好。

回答by Paul McCarthy

dependencies {
    implementation 'com.android.support:appcompat-v7:28.0.0'
}

compile has been replaced by implementation, don't know why.

compile 已经被 implementation 取代了,不知道为什么。

回答by Riga

Using Visual Studio 2015 (Windows7) + Xamarin had this error and after trying multiple things (installing packages, download android_m2repository_r10.zip...) ended removing the full Xamarin folderinside

使用 Visual Studio 2015 (Windows7) + Xamarin 出现此错误,在尝试多种操作(安装软件包、下载 android_m2repository_r10.zip...)后,最终删除了内部的完整Xamarin 文件夹

C:\Users\<my user>\AppData\Local
C:\Users\<my user>\AppData\Local

After that, Rebuild the application in VS and errors disappeared.

之后,在 VS 中重建应用程序,错误消失了。