android布局文件报错Failed to find '@attr/textAppearanceLabelLarge'


      如下布局的Button标签内包含这行代码  style="@style/Widget.Material3.Button.OutlinedButton.Icon"   导致报错
(Failed to find '@attr/textAppearanceLabelLarge' in current theme.)该怎么解决


布局文件内容
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/showChatsFragment"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="#000000"
    android:windowSoftInputMode="adjustPan|stateHidden"
    tools:context=".fragments.ShowChatsFragment">




        <Button
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_margin="16dp"
    
            app:icon="@drawable/ic_add"
            android:text="ADD CONTACT"
            android:textColor="@color/white"
            app:strokeColor="@color/white"
            app:strokeWidth="2dp"
            android:textSize="15sp"
            android:padding="10dp"
            android:elevation="2dp"
            app:iconSize="35sp"
            app:iconTint="@color/white"
            app:rippleColor="@color/white"
            app:iconPadding="5dp"
            app:layout_constraintBottom_toBottomOf="parent"
            app:layout_constraintEnd_toEndOf="parent" />




</FrameLayout>
不知道你这个问题是否已经解决, 如果还没有解决的话:
  • 以下回答来自chatgpt:

    这个问题的根本原因是编译器无法找到名为textAppearanceLabelLarge的定义。解决此问题有几种可能的方法:

    1. 检查attr.xml文件

    检查您的项目中是否有一个名为attr.xml的文件。这个文件应该包含所有自定义属性的定义。确保该文件中有一个类似于以下内容的定义:

    <attr name="textAppearanceLabelLarge" format="reference" />
    

    如果不存在,请创建这个文件并添加上述定义。

    1. 检查样式文件

    确保您的项目中有一个名为styles.xml的样式文件。您应该在其中定义您希望使用的样式,并在布局文件中使用这些样式。

    检查您的样式文件中是否有类似于以下内容的定义:

    <style name="TextAppearanceLabelLarge">
        <item name="android:textSize">@dimen/large_text_size</item>
        <item name="android:textStyle">bold</item>
        <item name="android:textColor">@color/black</item>
    </style>
    

    如果不存在,请创建这个样式并保存到styles.xml文件中。

    1. 清除缓存并重建项目

    通过清除Android Studio的缓存并重新构建项目,有可能解决这个问题。在Android Studio中依次点击File -> Invalidate Caches / Restart,然后重新构建项目。

    如果以上方法不起作用,您可以尝试使用其他的textAppearance属性或者直接使用textSize、textStyle、textColor等属性,或者搜索解决这个问题的其他可能的方案。


如果你已经解决了该问题, 非常希望你能够分享一下解决方案, 写成博客, 将相关链接放在评论区, 以帮助更多的人 ^-^