繁体   English   中英

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”项目中:

  • 从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 tarjet中检查Android 4.0。
  • 在“Java Build Path” - > Order and Export - >取消选中.jar库
  • 最后做一个“项目 - >清理”两个项目

如果您使用的是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中的回答

  1. 转到项目目录(或项目视图)
  2. 找到并打开.idea目录
  3. 删除缓存和库目录< - 这是必不可少的
  4. 使高速缓存/重新启动无效

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM