【问题标题】:Error retrieving parent for item: No resource found that matches the given name 'android:Theme.Material.Light'检索项目的父项时出错:找不到与给定名称“android:Theme.Material.Light”匹配的资源
【发布时间】:2015-01-07 04:13:04
【问题描述】:

我在 styles.xml 中收到此错误:

检索项目的父项时出错:未找到与 给定名称'android:Theme.Material.Light'。

在清单中:

<uses-sdk
    android:minSdkVersion="16"
    android:targetSdkVersion="21" />

Android SDK 管理器:

我更新了所有 api 21 和附加功能。

按顺序导出

values-v21/styles.xml:

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <style name="AppTheme" parent="android:Theme.Material.Light">

        <item name="android:colorPrimary">@color/primary</item>
        <item name="android:colorPrimaryDark">@color/primary_dark</item>
        <item name="android:colorAccent">@color/accent</item>
        <item name="android:textColorPrimary">@color/text_primary</item>
        <item name="android:textColor">@color/text_secondary</item>
        <item name="android:navigationBarColor">@color/primary_dark</item>

    </style>
</resources>  

控制台:

E:\workspace\WelcomeToL\app\src\main\res\values-v21\styles.xml:3: error: Error retrieving parent for item: No resource found that matches the given name 'android:Theme.Material.Light'.

E:\workspace\WelcomeToL\app\src\main\res\values-v21\styles.xml:7: error: Error: No resource found that matches the given name: attr 'android:colorAccent'.
 
E:\workspace\WelcomeToL\app\src\main\res\values-v21\styles.xml:5: error: Error: No resource found that matches the given name: attr 'android:colorPrimary'.
 
E:\workspace\WelcomeToL\app\src\main\res\values-v21\styles.xml:6: error: Error: No resource found that matches the given name: attr 'android:colorPrimaryDark'.

E:\workspace\WelcomeToL\app\src\main\res\values-v21\styles.xml:10: error: Error: No resource found that matches the given name: attr 'android:navigationBarColor'.

我不知道为什么仍然会出现此错误。任何人都可以帮助我。谢谢。

【问题讨论】:

    标签: android android-5.0-lollipop android-styles


    【解决方案1】:

    检索项目的父项时出错:未找到与 给定名称'android:Theme.Material.Light'。

    Material.Light 主题要求项目的 API 级别 21。将项目的 Project Build TargetProperties-&gt;Android-&gt;Project Build Target 设置为 API 21

    【讨论】:

    • targetSdkVersion 可以低于 21,但 compileSdkVersion 必须 >= 21
    猜你喜欢
    • 2017-10-27
    • 2014-06-04
    • 2017-02-10
    • 2017-06-27
    • 2017-09-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-12-27
    相关资源
    最近更新 更多