Failed to find '@attr/shapeAppearanceSmallComponent' in current theme
Asked Answered
G

5

7

I am trying to implement the chip layout in android, I have updated my google material dependency to its latest version as well. But the XML file is throwing this problem

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

gradle file

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 File

<?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>
Ginglymus answered 27/4, 2021 at 7:42 Comment(2)
In which file are you getting this issue? Post also your theme.Constrain
I am getting this issue in the XML file , Please checkGinglymus
M
2

you can try to change your Base application theme to the following:

<style name="Theme.AppTheme" parent="Theme.MaterialComponents.DayNight.DarkActionBar">
Monaco answered 28/4, 2021 at 7:11 Comment(2)
Thanks for helping, Your solution worked out pretty well.Ginglymus
Glad to hear that! :)Monaco
U
12

go to themes.xml and replace MaterialComponents with Material3 in the parent="" tag for exemple

check your theme is it is like that

<style name="Theme.baseapp" parent="Theme.MaterialComponents.Light.NoActionBar">

change it to be like that

<style name="Theme.baseapp" parent="Theme.Material3.Light.NoActionBar">
Umeh answered 10/7, 2022 at 20:50 Comment(0)
C
4

The shapeAppearanceSmallComponent attribute is defined in your theme.
To use the material components library you have to set a Theme.MaterialComponents theme.
For example:

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

</style>

If you cannot change your theme to inherit from a Material Components theme you can also use a Theme.MaterialComponents.Bridge theme

Constrain answered 28/4, 2021 at 15:6 Comment(0)
M
2

you can try to change your Base application theme to the following:

<style name="Theme.AppTheme" parent="Theme.MaterialComponents.DayNight.DarkActionBar">
Monaco answered 28/4, 2021 at 7:11 Comment(2)
Thanks for helping, Your solution worked out pretty well.Ginglymus
Glad to hear that! :)Monaco
N
1

Add for your theme:

<item name="textAppearanceTitleLarge">@style/TextAppearance.Material3.TitleLarge</item>
<item name="textAppearanceTitleMedium">@style/TextAppearance.Material3.TitleMedium</item>
<item name="textAppearanceTitleSmall">@style/TextAppearance.Material3.TitleSmall</item>
Norbert answered 13/12, 2022 at 11:43 Comment(0)
C
0

Had the same issue and this fixed it for me in the themes.xml file

<style name="Theme.AITutorApp" parent="Theme.MaterialComponents.DayNight.DarkActionBar.Bridge">
Capable answered 15/6, 2023 at 4:55 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.