android - 检索项目 : No resource found that matches the given name 'android:Theme.Material.Light' 的父项时出错

标签 android android-5.0-lollipop android-styles

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

Error retrieving parent for item: No resource found that matches the given name 'android:Theme.Material.Light'.

在 list 中:

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

Android SDK 管理器:

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

enter image description here

enter image description here

订购和导出:

enter image description here

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'.

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

最佳答案

Error retrieving parent for item: No resource found that matches the given name 'android:Theme.Material.Light'.

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

关于android - 检索项目 : No resource found that matches the given name 'android:Theme.Material.Light' 的父项时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27812302/

相关文章:

java - 在枚举中使用字符串资源并在 switch case 中使用

android - TextView的样式和android :textAppearance attributes?有什么区别

Android:如何将样式应用于 ViewGroup 的所有子级

java - 更改样式仅部分有效 : text color changes, 背景无效

android - 如何从 firebase 中的值中获取键

android - 从 Google 获取 json 响应将 API 放置在 android 中

android - GenyMotion 上的 INSTALL_FAILED_NO_MATCHING_ABIS

android - CardView 都相互堆叠

android - 如何在android中动画后刷新布局?

android - 在 Android 5+ 中使用 MediaCodec 进行的视频解码损坏