material-1.5.0-alpha03\res\values-v31\values-v31.xml:3:5-94:AAPT:错误:找不到资源 android:color/system_neutr
Posted
技术标签:
【中文标题】material-1.5.0-alpha03\\res\\values-v31\\values-v31.xml:3:5-94:AAPT:错误:找不到资源 android:color/system_neutral1_1000【英文标题】:material-1.5.0-alpha03\res\values-v31\values-v31.xml:3:5-94: AAPT: error: resource android:color/system_neutral1_1000 not foundmaterial-1.5.0-alpha03\res\values-v31\values-v31.xml:3:5-94:AAPT:错误:找不到资源 android:color/system_neutral1_1000 【发布时间】:2021-11-01 18:30:29 【问题描述】:<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="m3_ref_palette_dynamic_neutral0">@android:color/system_neutral1_1000</color>
<color name="m3_ref_palette_dynamic_neutral10">@android:color/system_neutral1_900</color>
<color name="m3_ref_palette_dynamic_neutral100">@android:color/system_neutral1_0</color>
<color name="m3_ref_palette_dynamic_neutral20">@android:color/system_neutral1_800</color>
<color name="m3_ref_palette_dynamic_neutral30">@android:color/system_neutral1_700</color>
<color name="m3_ref_palette_dynamic_neutral40">@android:color/system_neutral1_600</color>
<color name="m3_ref_palette_dynamic_neutral50">@android:color/system_neutral1_500</color>
<color name="m3_ref_palette_dynamic_neutral60">@android:color/system_neutral1_400</color>
<color name="m3_ref_palette_dynamic_neutral70">@android:color/system_neutral1_300</color>
<color name="m3_ref_palette_dynamic_neutral80">@android:color/system_neutral1_200</color>
<color name="m3_ref_palette_dynamic_neutral90">@android:color/system_neutral1_100</color>
<color name="m3_ref_palette_dynamic_neutral95">@android:color/system_neutral1_50</color>
<color name="m3_ref_palette_dynamic_neutral99">@android:color/system_neutral1_10</color>
<color name="m3_ref_palette_dynamic_neutral_variant0">@android:color/system_neutral2_1000</color>
<color name="m3_ref_palette_dynamic_neutral_variant10">@android:color/system_neutral2_900</color>
<color name="m3_ref_palette_dynamic_neutral_variant100">@android:color/system_neutral2_0</color>
<color name="m3_ref_palette_dynamic_neutral_variant20">@android:color/system_neutral2_800</color>
<color name="m3_ref_palette_dynamic_neutral_variant30">@android:color/system_neutral2_700</color>
<color name="m3_ref_palette_dynamic_neutral_variant40">@android:color/system_neutral2_600</color>
<color name="m3_ref_palette_dynamic_neutral_variant50">@android:color/system_neutral2_500</color>
<color name="m3_ref_palette_dynamic_neutral_variant60">@android:color/system_neutral2_400</color>
<color name="m3_ref_palette_dynamic_neutral_variant70">@android:color/system_neutral2_300</color>
<color name="m3_ref_palette_dynamic_neutral_variant80">@android:color/system_neutral2_200</color>
<color name="m3_ref_palette_dynamic_neutral_variant90">@android:color/system_neutral2_100</color>
<color name="m3_ref_palette_dynamic_neutral_variant95">@android:color/system_neutral2_50</color>
<color name="m3_ref_palette_dynamic_neutral_variant99">@android:color/system_neutral2_10</color>
<color name="m3_ref_palette_dynamic_primary0">@android:color/system_accent1_1000</color>
<color name="m3_ref_palette_dynamic_primary10">@android:color/system_accent1_900</color>
<color name="m3_ref_palette_dynamic_primary100">@android:color/system_accent1_0</color>
<color name="m3_ref_palette_dynamic_primary20">@android:color/system_accent1_800</color>
<color name="m3_ref_palette_dynamic_primary30">@android:color/system_accent1_700</color>
<color name="m3_ref_palette_dynamic_primary40">@android:color/system_accent1_600</color>
<color name="m3_ref_palette_dynamic_primary50">@android:color/system_accent1_500</color>
<color name="m3_ref_palette_dynamic_primary60">@android:color/system_accent1_400</color>
<color name="m3_ref_palette_dynamic_primary70">@android:color/system_accent1_300</color>
<color name="m3_ref_palette_dynamic_primary80">@android:color/system_accent1_200</color>
<color name="m3_ref_palette_dynamic_primary90">@android:color/system_accent1_100</color>
<color name="m3_ref_palette_dynamic_primary95">@android:color/system_accent1_50</color>
<color name="m3_ref_palette_dynamic_primary99">@android:color/system_accent1_10</color>
<color name="m3_ref_palette_dynamic_secondary0">@android:color/system_accent2_1000</color>
<color name="m3_ref_palette_dynamic_secondary10">@android:color/system_accent2_900</color>
<color name="m3_ref_palette_dynamic_secondary100">@android:color/system_accent2_0</color>
<color name="m3_ref_palette_dynamic_secondary20">@android:color/system_accent2_800</color>
<color name="m3_ref_palette_dynamic_secondary30">@android:color/system_accent2_700</color>
<color name="m3_ref_palette_dynamic_secondary40">@android:color/system_accent2_600</color>
<color name="m3_ref_palette_dynamic_secondary50">@android:color/system_accent2_500</color>
<color name="m3_ref_palette_dynamic_secondary60">@android:color/system_accent2_400</color>
<color name="m3_ref_palette_dynamic_secondary70">@android:color/system_accent2_300</color>
<color name="m3_ref_palette_dynamic_secondary80">@android:color/system_accent2_200</color>
<color name="m3_ref_palette_dynamic_secondary90">@android:color/system_accent2_100</color>
<color name="m3_ref_palette_dynamic_secondary95">@android:color/system_accent2_50</color>
<color name="m3_ref_palette_dynamic_secondary99">@android:color/system_accent2_10</color>
<color name="m3_ref_palette_dynamic_tertiary0">@android:color/system_accent3_1000</color>
<color name="m3_ref_palette_dynamic_tertiary10">@android:color/system_accent3_900</color>
<color name="m3_ref_palette_dynamic_tertiary100">@android:color/system_accent3_0</color>
<color name="m3_ref_palette_dynamic_tertiary20">@android:color/system_accent3_800</color>
<color name="m3_ref_palette_dynamic_tertiary30">@android:color/system_accent3_700</color>
<color name="m3_ref_palette_dynamic_tertiary40">@android:color/system_accent3_600</color>
<color name="m3_ref_palette_dynamic_tertiary50">@android:color/system_accent3_500</color>
<color name="m3_ref_palette_dynamic_tertiary60">@android:color/system_accent3_400</color>
<color name="m3_ref_palette_dynamic_tertiary70">@android:color/system_accent3_300</color>
<color name="m3_ref_palette_dynamic_tertiary80">@android:color/system_accent3_200</color>
<color name="m3_ref_palette_dynamic_tertiary90">@android:color/system_accent3_100</color>
<color name="m3_ref_palette_dynamic_tertiary95">@android:color/system_accent3_50</color>
<color name="m3_ref_palette_dynamic_tertiary99">@android:color/system_accent3_10</color>
<color name="m3_sys_color_dynamic_dark_background">@color/m3_ref_palette_dynamic_neutral10</color>
<color name="m3_sys_color_dynamic_dark_inverse_on_surface">@color/m3_ref_palette_dynamic_neutral20</color>
<color name="m3_sys_color_dynamic_dark_inverse_primary">@color/m3_ref_palette_dynamic_primary40</color>
<color name="m3_sys_color_dynamic_dark_inverse_surface">@color/m3_ref_palette_dynamic_neutral90</color>
<color name="m3_sys_color_dynamic_dark_on_background">@color/m3_ref_palette_dynamic_neutral90</color>
<color name="m3_sys_color_dynamic_dark_on_primary">@color/m3_ref_palette_dynamic_primary20</color>
<color name="m3_sys_color_dynamic_dark_on_primary_container">@color/m3_ref_palette_dynamic_primary90</color>
<color name="m3_sys_color_dynamic_dark_on_secondary">@color/m3_ref_palette_dynamic_secondary20</color>
<color name="m3_sys_color_dynamic_dark_on_secondary_container">@color/m3_ref_palette_dynamic_secondary90</color>
<color name="m3_sys_color_dynamic_dark_on_surface">@color/m3_ref_palette_dynamic_neutral90</color>
<color name="m3_sys_color_dynamic_dark_on_surface_variant">@color/m3_ref_palette_dynamic_neutral_variant80</color>
<color name="m3_sys_color_dynamic_dark_on_tertiary">@color/m3_ref_palette_dynamic_tertiary20</color>
<color name="m3_sys_color_dynamic_dark_on_tertiary_container">@color/m3_ref_palette_dynamic_tertiary90</color>
<color name="m3_sys_color_dynamic_dark_outline">@color/m3_ref_palette_dynamic_neutral_variant60</color>
<color name="m3_sys_color_dynamic_dark_primary">@color/m3_ref_palette_dynamic_primary80</color>
<color name="m3_sys_color_dynamic_dark_primary_container">@color/m3_ref_palette_dynamic_primary30</color>
<color name="m3_sys_color_dynamic_dark_secondary">@color/m3_ref_palette_dynamic_secondary80</color>
<color name="m3_sys_color_dynamic_dark_secondary_container">@color/m3_ref_palette_dynamic_secondary30</color>
<color name="m3_sys_color_dynamic_dark_surface">@color/m3_ref_palette_dynamic_neutral10</color>
<color name="m3_sys_color_dynamic_dark_surface_variant">@color/m3_ref_palette_dynamic_neutral_variant30</color>
<color name="m3_sys_color_dynamic_dark_tertiary">@color/m3_ref_palette_dynamic_tertiary80</color>
<color name="m3_sys_color_dynamic_dark_tertiary_container">@color/m3_ref_palette_dynamic_tertiary30</color>
<color name="m3_sys_color_dynamic_light_background">@color/m3_ref_palette_dynamic_neutral99</color>
<color name="m3_sys_color_dynamic_light_inverse_on_surface">@color/m3_ref_palette_dynamic_neutral95</color>
<color name="m3_sys_color_dynamic_light_inverse_primary">@color/m3_ref_palette_dynamic_primary80</color>
<color name="m3_sys_color_dynamic_light_inverse_surface">@color/m3_ref_palette_dynamic_neutral20</color>
<color name="m3_sys_color_dynamic_light_on_background">@color/m3_ref_palette_dynamic_neutral10</color>
<color name="m3_sys_color_dynamic_light_on_primary">@color/m3_ref_palette_dynamic_primary100</color>
<color name="m3_sys_color_dynamic_light_on_primary_container">@color/m3_ref_palette_dynamic_primary10</color>
<color name="m3_sys_color_dynamic_light_on_secondary">@color/m3_ref_palette_dynamic_secondary100</color>
<color name="m3_sys_color_dynamic_light_on_secondary_container">@color/m3_ref_palette_dynamic_secondary10</color>
<color name="m3_sys_color_dynamic_light_on_surface">@color/m3_ref_palette_dynamic_neutral10</color>
<color name="m3_sys_color_dynamic_light_on_surface_variant">@color/m3_ref_palette_dynamic_neutral_variant30</color>
<color name="m3_sys_color_dynamic_light_on_tertiary">@color/m3_ref_palette_dynamic_tertiary100</color>
<color name="m3_sys_color_dynamic_light_on_tertiary_container">@color/m3_ref_palette_dynamic_tertiary10</color>
<color name="m3_sys_color_dynamic_light_outline">@color/m3_ref_palette_dynamic_neutral_variant50</color>
<color name="m3_sys_color_dynamic_light_primary">@color/m3_ref_palette_dynamic_primary40</color>
<color name="m3_sys_color_dynamic_light_primary_container">@color/m3_ref_palette_dynamic_primary90</color>
<color name="m3_sys_color_dynamic_light_secondary">@color/m3_ref_palette_dynamic_secondary40</color>
<color name="m3_sys_color_dynamic_light_secondary_container">@color/m3_ref_palette_dynamic_secondary90</color>
<color name="m3_sys_color_dynamic_light_surface">@color/m3_ref_palette_dynamic_neutral99</color>
<color name="m3_sys_color_dynamic_light_surface_variant">@color/m3_ref_palette_dynamic_neutral_variant90</color>
<color name="m3_sys_color_dynamic_light_tertiary">@color/m3_ref_palette_dynamic_tertiary40</color>
<color name="m3_sys_color_dynamic_light_tertiary_container">@color/m3_ref_palette_dynamic_tertiary90</color>
<style name="ThemeOverlay.Material3.DynamicColors.Dark" parent="">
<!-- Color palettes -->
<item name="colorPrimary">@color/m3_sys_color_dynamic_dark_primary</item>
<item name="colorOnPrimary">@color/m3_sys_color_dynamic_dark_on_primary</item>
<item name="colorPrimaryInverse">@color/m3_sys_color_dynamic_dark_inverse_primary</item>
<item name="colorPrimaryContainer">@color/m3_sys_color_dynamic_dark_primary_container</item>
<item name="colorOnPrimaryContainer">@color/m3_sys_color_dynamic_dark_on_primary_container</item>
<item name="colorSecondary">@color/m3_sys_color_dynamic_dark_secondary</item>
<item name="colorOnSecondary">@color/m3_sys_color_dynamic_dark_on_secondary</item>
<item name="colorSecondaryContainer">@color/m3_sys_color_dynamic_dark_secondary_container</item>
<item name="colorOnSecondaryContainer">@color/m3_sys_color_dynamic_dark_on_secondary_container</item>
<item name="colorTertiary">@color/m3_sys_color_dynamic_dark_tertiary</item>
<item name="colorOnTertiary">@color/m3_sys_color_dynamic_dark_on_tertiary</item>
<item name="colorTertiaryContainer">@color/m3_sys_color_dynamic_dark_tertiary_container</item>
<item name="colorOnTertiaryContainer">@color/m3_sys_color_dynamic_dark_on_tertiary_container</item>
<item name="android:colorBackground">@color/m3_sys_color_dynamic_dark_background</item>
<item name="colorOnBackground">@color/m3_sys_color_dynamic_dark_on_background</item>
<item name="colorSurface">@color/m3_sys_color_dynamic_dark_surface</item>
<item name="colorOnSurface">@color/m3_sys_color_dynamic_dark_on_surface</item>
<item name="colorSurfaceVariant">@color/m3_sys_color_dynamic_dark_surface_variant</item>
<item name="colorOnSurfaceVariant">@color/m3_sys_color_dynamic_dark_on_surface_variant</item>
<item name="colorSurfaceInverse">@color/m3_sys_color_dynamic_dark_inverse_surface</item>
<item name="colorOnSurfaceInverse">@color/m3_sys_color_dynamic_dark_inverse_on_surface</item>
<item name="colorOutline">@color/m3_sys_color_dynamic_dark_outline</item>
<item name="colorError">@color/m3_sys_color_dark_error</item>
<item name="colorOnError">@color/m3_sys_color_dark_on_error</item>
<item name="colorErrorContainer">@color/m3_sys_color_dark_error_container</item>
<item name="colorOnErrorContainer">@color/m3_sys_color_dark_on_error_container</item>
</style>
<style name="ThemeOverlay.Material3.DynamicColors.DayNight" parent="ThemeOverlay.Material3.DynamicColors.Light"/>
<style name="ThemeOverlay.Material3.DynamicColors.Light" parent="">
<!-- Color palettes -->
<item name="colorPrimary">@color/m3_sys_color_dynamic_light_primary</item>
<item name="colorOnPrimary">@color/m3_sys_color_dynamic_light_on_primary</item>
<item name="colorPrimaryInverse">@color/m3_sys_color_dynamic_light_inverse_primary</item>
<item name="colorPrimaryContainer">@color/m3_sys_color_dynamic_light_primary_container</item>
<item name="colorOnPrimaryContainer">@color/m3_sys_color_dynamic_light_on_primary_container</item>
<item name="colorSecondary">@color/m3_sys_color_dynamic_light_secondary</item>
<item name="colorOnSecondary">@color/m3_sys_color_dynamic_light_on_secondary</item>
<item name="colorSecondaryContainer">@color/m3_sys_color_dynamic_light_secondary_container</item>
<item name="colorOnSecondaryContainer">@color/m3_sys_color_dynamic_light_on_secondary_container</item>
<item name="colorTertiary">@color/m3_sys_color_dynamic_light_tertiary</item>
<item name="colorOnTertiary">@color/m3_sys_color_dynamic_light_on_tertiary</item>
<item name="colorTertiaryContainer">@color/m3_sys_color_dynamic_light_tertiary_container</item>
<item name="colorOnTertiaryContainer">@color/m3_sys_color_dynamic_light_on_tertiary_container</item>
<item name="android:colorBackground">@color/m3_sys_color_dynamic_light_background</item>
<item name="colorOnBackground">@color/m3_sys_color_dynamic_light_on_background</item>
<item name="colorSurface">@color/m3_sys_color_dynamic_light_surface</item>
<item name="colorOnSurface">@color/m3_sys_color_dynamic_light_on_surface</item>
<item name="colorSurfaceVariant">@color/m3_sys_color_dynamic_light_surface_variant</item>
<item name="colorOnSurfaceVariant">@color/m3_sys_color_dynamic_light_on_surface_variant</item>
<item name="colorSurfaceInverse">@color/m3_sys_color_dynamic_light_inverse_surface</item>
<item name="colorOnSurfaceInverse">@color/m3_sys_color_dynamic_light_inverse_on_surface</item>
<item name="colorOutline">@color/m3_sys_color_dynamic_light_outline</item>
<item name="colorError">@color/m3_sys_color_light_error</item>
<item name="colorOnError">@color/m3_sys_color_light_on_error</item>
<item name="colorErrorContainer">@color/m3_sys_color_light_error_container</item>
<item name="colorOnErrorContainer">@color/m3_sys_color_light_on_error_container</item>
</style>
</resources>
这是我的v31/values-v31
当我尝试构建这个项目时。我经常收到这个错误(
错误:C:\Users\Dell.gradle\caches\transforms-2\files-2.1\66e9dd10963e7a2704a4a2116f19e6fb\material-1.5.0-alpha03\res\values-v31\values-v31.xml:3:5- 94:AAPT:错误:资源 android:color/system_neutral1_1000 未找到。)
我尝试过的解决方案
重建项目,清理项目,使缓存无效并重新启动,enter code here
并删除并重新创建该模拟器,但对我没有任何效果
【问题讨论】:
【参考方案1】:如release notes中所述:
1.5.0-alpha03
版本引入了新的Material 3 themes 和
使用此版本的库时,请务必将您应用的
compileSdkVersion
更新为 31。
【讨论】:
【参考方案2】:简答:
要修复编译错误,请确保在使用时将应用的
compileSdkVersion
更新为 31 新版本的材料组件库。或者,您可以将 Material Components 库降级为
1.4.0
或1.5.0-alpha02
。
说明:
从版本 1.5.0-alpha03
开始,材料组件库需要编译 SDK 版本 31(在提交 40509dc 时提出)。
见release notes on GitHub。
这是必需的,因为新的 Material 3 themes 支持 dynamic colors。 从 Android S (API 31) 开始,该框架能够根据用户在设备上的壁纸或颜色选择在您的 UI 中支持动态颜色。
阅读更多关于“Material You”壁纸主题系统“Monet”的信息,该系统是该功能的基础:https://***.com/a/69065800/1816338https://medium.com/@xch3dx/using-material-you-in-your-app-15ec982eecb4
【讨论】:
这是正确答案【参考方案3】:问题出在下面一行:
implementation 'com.google.android.material:material:1.5.0-alpha03'
我使用了这个并且得到了同样的错误。用以下行替换它可以解决问题:
implementation 'com.google.android.material:material:1.5.0-alpha02')
【讨论】:
这似乎也为我解决了;谢谢。 不,这不是真正的解决方案。 但这是降级依赖...【参考方案4】:我遇到了这个错误,它已经解决了。更改或降级您的依赖项应该可以解决此问题。如果您在此link 中遇到此错误,我建议您应该同时更改这两个,来自:
implementation 'androidx.appcompat:appcompat:1.4.0'
implementation 'com.google.android.material:material:1.5.0'
到:
implementation 'androidx.appcompat:appcompat:1.3.0'
implementation 'com.google.android.material:material:1.4.0'
然后,再次运行您的应用程序。我认为这种方法有效。如果您创建新项目,但在尝试运行应用时没有注意到此错误,通常会发生这种情况。
【讨论】:
谢谢,成功了。 解决了我的问题【参考方案5】:在 Java 项目中尝试以 API 30 为目标时,我也遇到了这个错误。我曾尝试仅降级 appcompat
依赖项,并收到此错误。事实证明,您还需要关闭 material
依赖项。
要针对 API 30,您需要将 androidx.appcompat:appcompat
和 com.google.android.material:material
都降级到旧版本。
从以下位置更改版本:
implementation 'androidx.appcompat:appcompat:1.4.1'
implementation 'com.google.android.material:material:1.5.0'
收件人:
implementation 'androidx.appcompat:appcompat:1.3.1'
implementation 'com.google.android.material:material:1.4.0'
【讨论】:
以上是关于material-1.5.0-alpha03\res\values-v31\values-v31.xml:3:5-94:AAPT:错误:找不到资源 android:color/system_neutr的主要内容,如果未能解决你的问题,请参考以下文章