Why when the application is running it quits the application and shows this error to me?

Error inflating class com.google.android.material.textfield.TextInputLayout Caused by: java.lang.reflect.InvocationTargetException at java.lang.reflect.Constructor.newInstance0(Native Method) at java.lang.reflect.Constructor.newInstance(Constructor.java:343) at android.view.LayoutInflater.createView(LayoutInflater.java:854) at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:1006) at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:961) at android.view.LayoutInflater.rInflate(LayoutInflater.java:1123) at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:1084) at android.view.LayoutInflater.inflate(LayoutInflater.java:682) at android.view.LayoutInflater.inflate(LayoutInflater.java:534) at android.view.LayoutInflater.inflate(LayoutInflater.java:481) at androidx.appcompat.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:555) at androidx.appcompat.app.AppCompatActivity.setContentView(AppCompatActivity.java:161) at omari.hamza.storyviewdemo.womenmask.adwan_app.Add_repices.onCreate(Add_repices.java:21) at android.app.Activity.performCreate(Activity.java:7957) at android.app.Activity.performCreate(Activity.java:7946) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1307) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3598) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3775) at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:83) at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135) at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2261) at android.os.Handler.dispatchMessage(Handler.java:107) at android.os.Looper.loop(Looper.java:237) at android.app.ActivityThread.main(ActivityThread.java:8107) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:496) 2020-09-24 18:23:34.281 24780-24780/omari.hamza.storyviewdemo.womenmask.adwan_app E/AndroidRuntime: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1100) Caused by: java.lang.IllegalArgumentException: The style on this component requires your app theme to be Theme.MaterialComponents (or a descendant). at com.google.android.material.internal.ThemeEnforcement.checkTheme(ThemeEnforcement.java:243) at com.google.android.material.internal.ThemeEnforcement.checkMaterialTheme(ThemeEnforcement.java:217) at com.google.android.material.internal.ThemeEnforcement.checkCompatibleTheme(ThemeEnforcement.java:145) at com.google.android.material.internal.ThemeEnforcement.obtainTintedStyledAttributes(ThemeEnforcement.java:115) at com.google.android.material.textfield.TextInputLayout.(TextInputLayout.java:460) at com.google.android.material.textfield.TextInputLayout.(TextInputLayout.java:419) ... 28 more

  **xml**
    
    
         <com.google.android.material.textfield.TextInputLayout
            android:id="@+id/textField"
            android:layout_width="match_parent"
            android:layout_marginTop="25dp"
            style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
    
            app:errorEnabled="true"
            app:counterEnabled="true"
            app:counterMaxLength="100"
        android:layout_height="wrap_content"
    
            android:hint="Componot">
    
    
        <com.google.android.material.textfield.TextInputEditText
                android:inputType="textCapWords"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                />
    
        </com.google.android.material.textfield.TextInputLayout>
**style** 

 
       <style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
                <!-- Customize your theme here. -->
                <item name="colorPrimary">#2986DA</item>
                <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
                <item name="colorAccent">@color/colorAccent</item>
              
            </style>

**gradle**


        implementation 'com.google.android.material:material:1.2.0'

1 answer

  • answered 2020-09-24 15:43 Kristy Welsh

    Your style needs to be a child of a Material Theme.

    java.lang.IllegalArgumentException: The style on this component requires your app theme to be Theme.MaterialComponents (or a descendant). at