在当前主题中找不到“@attr/shapeAppearanceSmallComponent”

Failed to find '@attr/shapeAppearanceSmallComponent' in current theme

我正在尝试在 android 中实现芯片布局,我也已将 google material 依赖项更新到其最新版本。但是 XML 文件抛出了这个问题

Failed to find '@attr/shapeAppearanceSmallComponent' in current theme.

gradle 文件

allprojects {
    repositories {
        google()
        jcenter()

        maven {
            url 'https://jitpack.io'
        }

    }
}


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

</style>

<style name="AppTheme.NoActionBar">
    <item name="windowActionBar">false</item>
    <item name="windowNoTitle">true</item>
</style>

XML 文件

<?xml version="1.0" encoding="utf-8"?>
<com.google.android.material.chip.ChipGroup
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/chipGroup"
    android:layout_width="match_parent"
    android:layout_height="wrap_content">

    <com.google.android.material.chip.Chip
        android:id="@+id/chip"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="text" />

</com.google.android.material.chip.ChipGroup>

您可以尝试将您的 Base 应用程序主题更改为以下内容:

<style name="Theme.AppTheme" parent="Theme.MaterialComponents.DayNight.DarkActionBar">

shapeAppearanceSmallComponent 属性已在您的主题中定义。
要使用 material 组件库,您必须设置 Theme.MaterialComponents theme.
例如:

<style name="AppTheme" parent="Theme.MaterialComponents.DayNight.NoActionBar">
    <!-- Customize your theme here. -->

</style>

如果您无法将主题更改为继承自 Material 组件主题,您也可以使用 Theme.MaterialComponents.Bridge theme