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

问题描述 投票:16回答:5

如何正确使用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>
java android adt
5个回答
16
投票

在“android-support-v7-appcompat”项目中:

  • 从Package explorer中删除“android-support-v7-appcompat”。
  • 再次导入并选中“复制到工作区”
  • 在属性 - > Android - >在项目构建目标中,取消选中Android 2.2并检查Android 4.1.2
  • 在Java构建路径中,取消选中是否有任何.jar库,并取消选中Dependences

另一方面,使用“android-support-v7-appcompat”的项目:

  • 在属性 - > Android中添加库,但取消选中“IsLibrary”。
  • 在Android - > Project build target中检查Android 4.0。
  • 在“Java Build Path” - > Order and Export - >取消选中.jar库
  • 最后做一个“项目 - >清理”两个项目

7
投票

如果您使用的是Gradle,则说明最新版本的兼容性库存在问题。

如果你的build.gradle文件中有以下内容,最后带有'+'

dependencies {
    compile 'com.android.support:appcompat-v7:+'
}

然后它可能会抓住你想要的更高版本的库。

将依赖项更改为:

dependencies {
    compile 'com.android.support:appcompat-v7:18.0+'
}

可以解决你的问题。


5
投票

你能试试吗?

android:theme="Theme.AppCompat.Light.DarkActionBar"

代替

android:theme="@style/Theme.AppCompat.Light.DarkActionBar"

0
投票

在您的应用程序依赖项文件中检查您是否具有依赖项

compile 'com.android.support:appcompatv[anything here]

要么

implement 'com.android.support:appcompat[anything here]

删除或注释掉它们,点击“灯泡”进行自动建议,然后选择添加库依赖项。 qazxsw poi

滚动第一个appcompat版本的选项。该库将添加到依赖项列表下方。重建应用程序或使缓存无效并重新启动

在一种情况下,这没有用,并且转到包含项目的文件夹,删除.gradle文件并重新启动Android Studio已经有效。来自Sneh Pandya在clicking on the autofillbulb for appcompat的回答


0
投票
  1. 转到项目目录(或项目视图)
  2. 找到并打开.idea目录
  3. 删除缓存和库目录< - 这是必不可少的
  4. 使高速缓存/重新启动无效
© www.soinside.com 2019 - 2024. All rights reserved.