Java Android资源链接失败的值,styles.xml

Java Android资源链接失败的值,styles.xml,java,android,android-studio,mobile,build.gradle,Java,Android,Android Studio,Mobile,Build.gradle,所以我想创建一个新的android项目,然后突然出现了一个错误,说android资源链接失败了,下面是我的代码 Styles.xml resources> <!-- Base application theme. --> <style type ="attr" name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar"> <!-- Customize your th

所以我想创建一个新的android项目,然后突然出现了一个错误,说android资源链接失败了,下面是我的代码

Styles.xml

resources>

    <!-- Base application theme. -->
    <style type ="attr" name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
        <!-- Customize your theme here. -->
        <item type="attr" name="colorPrimary">@color/colorPrimary</item>
        <item type="attr" name="colorPrimaryDark">@color/colorPrimaryDark</item>
        <item type="attr" name="colorAccent">@color/colorAccent</item>
    </style>

</resources>


使用类似于此的方法不要添加类型属性。这可能对你有帮助

 <style name="AppTheme" parent="Base.Theme.MaterialComponents.Light.DarkActionBar">
    <item name="colorPrimary">@color/colorPrimary</item>
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
    <item name="colorAccent">@color/colorAccent</item>
</style>

@颜色/原色
@颜色/原色暗
@颜色/颜色重音
请尝试删除所有标记中的type=“attr”
 <style name="AppTheme" parent="Base.Theme.MaterialComponents.Light.DarkActionBar">
    <item name="colorPrimary">@color/colorPrimary</item>
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
    <item name="colorAccent">@color/colorAccent</item>
</style>