title: Error: Inflating class com.google.android.material.textfield.TextInputLayout
body: <p>I am getting the error, here is my XML file</p>
  <pre><code>&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
  &lt;RelativeLayout xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;
      xmlns:tools=&quot;http://schemas.android.com/tools&quot;
      android:layout_width=&quot;match_parent&quot;
      android:layout_height=&quot;match_parent&quot;
      android:orientation=&quot;vertical&quot;
      tools:context=&quot;.BMIActivity&quot;&gt;
  
      &lt;androidx.appcompat.widget.Toolbar
          android:id=&quot;@+id/toolbar_bmi_activity&quot;
          android:layout_width=&quot;match_parent&quot;
          android:layout_height=&quot;?android:attr/actionBarSize&quot;
          android:background=&quot;#FFFFFF&quot; /&gt;
  
      &lt;RadioGroup
          android:id=&quot;@+id/rgUnits&quot;
          android:layout_width=&quot;match_parent&quot;
          android:layout_height=&quot;wrap_content&quot;
          android:layout_below=&quot;@id/toolbar_bmi_activity&quot;
          android:layout_margin=&quot;10dp&quot;
          android:background=&quot;@drawable/drawable_radio_group_tab_background&quot;
          android:orientation=&quot;horizontal&quot;&gt;
  
          &lt;RadioButton
              android:id=&quot;@+id/rbMetricUnits&quot;
              android:layout_width=&quot;0dp&quot;
              android:layout_height=&quot;35dp&quot;
              android:layout_weight=&quot;0.50&quot;
              android:background=&quot;@drawable/drawable_units_tab_selector&quot;
              android:button=&quot;@null&quot;
              android:checked=&quot;true&quot;
              android:gravity=&quot;center&quot;
              android:text=&quot;METRIC UNITS&quot;
              android:textColor=&quot;@drawable/drawable_units_tab_text_color_selector&quot;
              android:textSize=&quot;16sp&quot;
              android:textStyle=&quot;bold&quot; /&gt;
  
          &lt;RadioButton
              android:id=&quot;@+id/rbUsUnits&quot;
              android:layout_width=&quot;0dp&quot;
              android:layout_height=&quot;35dp&quot;
              android:layout_weight=&quot;0.50&quot;
              android:background=&quot;@drawable/drawable_units_tab_selector&quot;
              android:button=&quot;@null&quot;
              android:checked=&quot;false&quot;
              android:gravity=&quot;center&quot;
              android:text=&quot;US UNITS&quot;
              android:textColor=&quot;@drawable/drawable_units_tab_text_color_selector&quot;
              android:textSize=&quot;16sp&quot;
              android:textStyle=&quot;bold&quot; /&gt;
      &lt;/RadioGroup&gt;
  
      &lt;LinearLayout
          android:id=&quot;@+id/llUnitsView&quot;
          android:layout_width=&quot;match_parent&quot;
          android:layout_height=&quot;match_parent&quot;
          android:layout_below=&quot;@id/rgUnits&quot;
          android:orientation=&quot;vertical&quot;
          android:padding=&quot;10dp&quot;&gt;
  
          &lt;LinearLayout
              android:id=&quot;@+id/llMetricUnitsView&quot;
              android:layout_width=&quot;match_parent&quot;
              android:layout_height=&quot;wrap_content&quot;
              android:orientation=&quot;vertical&quot;&gt;
  
              &lt;com.google.android.material.textfield.TextInputLayout
                  android:id=&quot;@+id/tilMetricUnitWeight&quot;
                  style=&quot;@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox&quot;
                  android:layout_width=&quot;match_parent&quot;
                  android:layout_height=&quot;wrap_content&quot;&gt;
  
                  &lt;androidx.appcompat.widget.AppCompatEditText
                      android:id=&quot;@+id/etMetricUnitWeight&quot;
                      android:layout_width=&quot;match_parent&quot;
                      android:layout_height=&quot;wrap_content&quot;
                      android:hint=&quot;WEIGHT (in kg)&quot;
                      android:inputType=&quot;numberDecimal&quot;
                      android:textSize=&quot;16sp&quot; /&gt;
              &lt;/com.google.android.material.textfield.TextInputLayout&gt;
  
              &lt;com.google.android.material.textfield.TextInputLayout
                  android:id=&quot;@+id/tilMetricUnitHeight&quot;
                  style=&quot;@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox&quot;
                  android:layout_width=&quot;match_parent&quot;
                  android:layout_height=&quot;wrap_content&quot;
                  android:layout_marginTop=&quot;10dp&quot;&gt;
  
                  &lt;androidx.appcompat.widget.AppCompatEditText
                      android:id=&quot;@+id/etMetricUnitHeight&quot;
                      android:layout_width=&quot;match_parent&quot;
                      android:layout_height=&quot;wrap_content&quot;
                      android:hint=&quot;HEIGHT (in cm)&quot;
                      android:inputType=&quot;numberDecimal&quot;
                      android:textSize=&quot;16sp&quot; /&gt;
              &lt;/com.google.android.material.textfield.TextInputLayout&gt;
          &lt;/LinearLayout&gt;
  
          &lt;LinearLayout
              android:id=&quot;@+id/llUsUnitsView&quot;
              android:layout_width=&quot;match_parent&quot;
              android:layout_height=&quot;wrap_content&quot;
              android:orientation=&quot;vertical&quot;
              android:visibility=&quot;gone&quot;
              tools:visibility=&quot;visible&quot;&gt;
  
              &lt;com.google.android.material.textfield.TextInputLayout
                  android:id=&quot;@+id/tilUsUnitWeight&quot;
                  style=&quot;@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox&quot;
                  android:layout_width=&quot;match_parent&quot;
                  android:layout_height=&quot;wrap_content&quot;&gt;
  
                  &lt;androidx.appcompat.widget.AppCompatEditText
                      android:id=&quot;@+id/etUsUnitWeight&quot;
                      android:layout_width=&quot;match_parent&quot;
                      android:layout_height=&quot;wrap_content&quot;
                      android:hint=&quot;WEIGHT (in lbs)&quot;
                      android:inputType=&quot;numberDecimal&quot;
                      android:textSize=&quot;16sp&quot; /&gt;
              &lt;/com.google.android.material.textfield.TextInputLayout&gt;
  
              &lt;LinearLayout
                  android:id=&quot;@+id/llUsUnitsHeight&quot;
                  android:layout_width=&quot;match_parent&quot;
                  android:layout_height=&quot;wrap_content&quot;
                  android:layout_marginTop=&quot;10dp&quot;
                  android:baselineAligned=&quot;false&quot;
                  android:orientation=&quot;horizontal&quot;&gt;
  
                  &lt;com.google.android.material.textfield.TextInputLayout
                      android:id=&quot;@+id/tilUsUnitHeightFeet&quot;
                      style=&quot;@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox&quot;
                      android:layout_width=&quot;0dp&quot;
                      android:layout_height=&quot;wrap_content&quot;
                      android:layout_marginEnd=&quot;5dp&quot;
                      android:layout_weight=&quot;1&quot;&gt;
  
                      &lt;androidx.appcompat.widget.AppCompatEditText
                          android:id=&quot;@+id/etUsUnitHeightFeet&quot;
                          android:layout_width=&quot;match_parent&quot;
                          android:layout_height=&quot;wrap_content&quot;
                          android:hint=&quot;Feet&quot;
                          android:inputType=&quot;number&quot;
                          android:textSize=&quot;16sp&quot; /&gt;
                  &lt;/com.google.android.material.textfield.TextInputLayout&gt;
  
                  &lt;com.google.android.material.textfield.TextInputLayout
                      android:id=&quot;@+id/tilUsUnitHeightInch&quot;
                      style=&quot;@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox&quot;
                      android:layout_width=&quot;0dp&quot;
                      android:layout_height=&quot;wrap_content&quot;
                      android:layout_marginStart=&quot;5dp&quot;
                      android:layout_weight=&quot;1&quot;&gt;
  
                      &lt;androidx.appcompat.widget.AppCompatEditText
                          android:id=&quot;@+id/etUsUnitHeightInch&quot;
                          android:layout_width=&quot;match_parent&quot;
                          android:layout_height=&quot;wrap_content&quot;
                          android:hint=&quot;Inch&quot;
                          android:inputType=&quot;number&quot;
                          android:textSize=&quot;16sp&quot; /&gt;
                  &lt;/com.google.android.material.textfield.TextInputLayout&gt;
  
              &lt;/LinearLayout&gt;
          &lt;/LinearLayout&gt;
  
          &lt;LinearLayout
              android:id=&quot;@+id/llDiplayBMIResult&quot;
              android:layout_width=&quot;match_parent&quot;
              android:layout_height=&quot;wrap_content&quot;
              android:layout_marginTop=&quot;25dp&quot;
              android:orientation=&quot;vertical&quot;
              android:visibility=&quot;visible&quot;
              tools:visibility=&quot;visible&quot;&gt;
  
              &lt;TextView
                  android:id=&quot;@+id/tvYourBMI&quot;
                  android:layout_width=&quot;match_parent&quot;
                  android:layout_height=&quot;wrap_content&quot;
                  android:gravity=&quot;center&quot;
                  android:text=&quot;YOUR BMI&quot;
                  android:textAllCaps=&quot;true&quot;
                  android:visibility=&quot;invisible&quot;
                  android:textSize=&quot;16sp&quot; /&gt;
  
              &lt;TextView
                  android:id=&quot;@+id/tvBMIValue&quot;
                  android:layout_width=&quot;match_parent&quot;
                  android:layout_height=&quot;wrap_content&quot;
                  android:layout_marginTop=&quot;5dp&quot;
                  android:gravity=&quot;center&quot;
                  android:textSize=&quot;18sp&quot;
                  android:textStyle=&quot;bold&quot;
                  tools:text=&quot;15.00&quot; /&gt;
  
              &lt;TextView
                  android:id=&quot;@+id/tvBMIType&quot;
                  android:layout_width=&quot;match_parent&quot;
                  android:layout_height=&quot;wrap_content&quot;
                  android:layout_marginTop=&quot;5dp&quot;
                  android:gravity=&quot;center&quot;
                  android:textSize=&quot;18sp&quot;
                  tools:text=&quot;Normal&quot; /&gt;
  
              &lt;TextView
                  android:id=&quot;@+id/tvBMIDescription&quot;
                  android:layout_width=&quot;match_parent&quot;
                  android:layout_height=&quot;wrap_content&quot;
                  android:layout_marginTop=&quot;5dp&quot;
                  android:gravity=&quot;center&quot;
                  android:textSize=&quot;18sp&quot;
                  tools:text=&quot;Normal&quot; /&gt;
          &lt;/LinearLayout&gt;
  
          &lt;Button
              android:id=&quot;@+id/btnCalculateUnits&quot;
              android:layout_width=&quot;match_parent&quot;
              android:layout_height=&quot;wrap_content&quot;
              android:layout_gravity=&quot;bottom&quot;
              android:layout_marginTop=&quot;35dp&quot;
              android:background=&quot;@color/colorAccent&quot;
              android:text=&quot;CALCULATE&quot;
              android:textColor=&quot;#FFFFFF&quot;
              android:textSize=&quot;18sp&quot; /&gt;
      &lt;/LinearLayout&gt;
  &lt;/RelativeLayout&gt;
  </code></pre>
  <p>and here is styles.xml</p>
  <pre><code>&lt;resources&gt;
  
      &lt;!-- Base application theme. --&gt;
      &lt;style name=&quot;AppTheme&quot; parent=&quot;Theme.AppCompat.Light.DarkActionBar&quot;&gt;
          &lt;!-- Customize your theme here. --&gt;
          &lt;item name=&quot;colorPrimary&quot;&gt;@color/colorPrimary&lt;/item&gt;
          &lt;item name=&quot;colorPrimaryDark&quot;&gt;@color/colorPrimaryDark&lt;/item&gt;
          &lt;item name=&quot;colorAccent&quot;&gt;@color/colorAccent&lt;/item&gt;
      &lt;/style&gt;
  &lt;/resources&gt;
  
  </code></pre>
  <p>Here is the stacktrace</p>
  <pre><code>2021-04-29 16:49:39.077 5682-5682/? I/nminutesworkou: Not late-enabling -Xcheck:jni (already on)
  2021-04-29 16:49:39.090 5682-5682/? I/nminutesworkou: Unquickening 12 vdex files!
  2021-04-29 16:49:39.100 5682-5682/? W/nminutesworkou: Unexpected CPU variant for X86 using defaults: x86
  2021-04-29 16:49:39.434 5682-5682/com.example.sevenminutesworkout D/NetworkSecurityConfig: No Network Security Config specified, using platform default
  2021-04-29 16:49:39.436 5682-5682/com.example.sevenminutesworkout D/NetworkSecurityConfig: No Network Security Config specified, using platform default
  2021-04-29 16:49:39.466 5682-5710/com.example.sevenminutesworkout D/libEGL: loaded /vendor/lib/egl/libEGL_emulation.so
  2021-04-29 16:49:39.472 5682-5710/com.example.sevenminutesworkout D/libEGL: loaded /vendor/lib/egl/libGLESv1_CM_emulation.so
  2021-04-29 16:49:39.478 5682-5710/com.example.sevenminutesworkout D/libEGL: loaded /vendor/lib/egl/libGLESv2_emulation.so
  2021-04-29 16:49:39.585 5682-5682/com.example.sevenminutesworkout W/nminutesworkou: Accessing hidden method Landroid/view/View;-&gt;computeFitSystemWindows(Landroid/graphics/Rect;Landroid/graphics/Rect;)Z (greylist, reflection, allowed)
  2021-04-29 16:49:39.588 5682-5682/com.example.sevenminutesworkout W/nminutesworkou: Accessing hidden method Landroid/view/ViewGroup;-&gt;makeOptionalFitsSystemWindows()V (greylist, reflection, allowed)
  2021-04-29 16:49:39.655 5682-5708/com.example.sevenminutesworkout D/HostConnection: HostConnection::get() New Host Connection established 0xf6a1f110, tid 5708
  2021-04-29 16:49:39.659 5682-5708/com.example.sevenminutesworkout D/HostConnection: HostComposition ext ANDROID_EMU_CHECKSUM_HELPER_v1 ANDROID_EMU_native_sync_v2 ANDROID_EMU_native_sync_v3 ANDROID_EMU_native_sync_v4 ANDROID_EMU_dma_v1 ANDROID_EMU_direct_mem ANDROID_EMU_host_composition_v1 ANDROID_EMU_host_composition_v2 ANDROID_EMU_vulkan ANDROID_EMU_deferred_vulkan_commands ANDROID_EMU_vulkan_null_optional_strings ANDROID_EMU_vulkan_create_resources_with_requirements ANDROID_EMU_YUV_Cache ANDROID_EMU_async_unmap_buffer ANDROID_EMU_vulkan_ignored_handles ANDROID_EMU_vulkan_free_memory_sync ANDROID_EMU_vulkan_shader_float16_int8 ANDROID_EMU_vulkan_async_queue_submit GL_OES_vertex_array_object GL_KHR_texture_compression_astc_ldr ANDROID_EMU_host_side_tracing ANDROID_EMU_async_frame_commands ANDROID_EMU_gles_max_version_2 
  2021-04-29 16:49:39.661 5682-5708/com.example.sevenminutesworkout W/OpenGLRenderer: Failed to choose config with EGL_SWAP_BEHAVIOR_PRESERVED, retrying without...
  2021-04-29 16:49:39.670 5682-5708/com.example.sevenminutesworkout D/EGL_emulation: eglCreateContext: 0xf6a1fb20: maj 2 min 0 rcv 2
  2021-04-29 16:49:39.674 5682-5708/com.example.sevenminutesworkout D/EGL_emulation: eglMakeCurrent: 0xf6a1fb20: ver 2 0 (tinfo 0xf6d70170) (first time)
  2021-04-29 16:49:39.698 5682-5708/com.example.sevenminutesworkout I/Gralloc4: mapper 4.x is not supported
  2021-04-29 16:49:39.700 5682-5708/com.example.sevenminutesworkout D/HostConnection: createUnique: call
  2021-04-29 16:49:39.700 5682-5708/com.example.sevenminutesworkout D/HostConnection: HostConnection::get() New Host Connection established 0xf6a1fb90, tid 5708
  2021-04-29 16:49:39.722 5682-5708/com.example.sevenminutesworkout D/goldfish-address-space: allocate: Ask for block of size 0x100
  2021-04-29 16:49:39.723 5682-5708/com.example.sevenminutesworkout D/goldfish-address-space: allocate: ioctl allocate returned offset 0x3fbcae000 size 0x2000
  2021-04-29 16:49:39.728 5682-5708/com.example.sevenminutesworkout D/HostConnection: HostComposition ext ANDROID_EMU_CHECKSUM_HELPER_v1 ANDROID_EMU_native_sync_v2 ANDROID_EMU_native_sync_v3 ANDROID_EMU_native_sync_v4 ANDROID_EMU_dma_v1 ANDROID_EMU_direct_mem ANDROID_EMU_host_composition_v1 ANDROID_EMU_host_composition_v2 ANDROID_EMU_vulkan ANDROID_EMU_deferred_vulkan_commands ANDROID_EMU_vulkan_null_optional_strings ANDROID_EMU_vulkan_create_resources_with_requirements ANDROID_EMU_YUV_Cache ANDROID_EMU_async_unmap_buffer ANDROID_EMU_vulkan_ignored_handles ANDROID_EMU_vulkan_free_memory_sync ANDROID_EMU_vulkan_shader_float16_int8 ANDROID_EMU_vulkan_async_queue_submit GL_OES_vertex_array_object GL_KHR_texture_compression_astc_ldr ANDROID_EMU_host_side_tracing ANDROID_EMU_async_frame_commands ANDROID_EMU_gles_max_version_2 
  2021-04-29 16:49:44.812 5682-5682/com.example.sevenminutesworkout D/AndroidRuntime: Shutting down VM
  2021-04-29 16:49:44.822 5682-5682/com.example.sevenminutesworkout E/AndroidRuntime: FATAL EXCEPTION: main
      Process: com.example.sevenminutesworkout, PID: 5682
      java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.sevenminutesworkout/com.example.sevenminutesworkout.BMIActivity}: android.view.InflateException: Binary XML file line #67 in com.example.sevenminutesworkout:layout/activity_bmi: Binary XML file line #67 in com.example.sevenminutesworkout:layout/activity_bmi: Error inflating class com.google.android.material.textfield.TextInputLayout
          at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3449)
          at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3601)
          at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:85)
          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:2066)
          at android.os.Handler.dispatchMessage(Handler.java:106)
          at android.os.Looper.loop(Looper.java:223)
          at android.app.ActivityThread.main(ActivityThread.java:7656)
          at java.lang.reflect.Method.invoke(Native Method)
          at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
          at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)
       Caused by: android.view.InflateException: Binary XML file line #67 in com.example.sevenminutesworkout:layout/activity_bmi: Binary XML file line #67 in com.example.sevenminutesworkout:layout/activity_bmi: Error inflating class com.google.android.material.textfield.TextInputLayout
       Caused by: android.view.InflateException: Binary XML file line #67 in com.example.sevenminutesworkout:layout/activity_bmi: 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:852)
          at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:1004)
          at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:959)
          at android.view.LayoutInflater.rInflate(LayoutInflater.java:1121)
          at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:1082)
          at android.view.LayoutInflater.rInflate(LayoutInflater.java:1124)
          at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:1082)
          at android.view.LayoutInflater.rInflate(LayoutInflater.java:1124)
          at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:1082)
          at android.view.LayoutInflater.inflate(LayoutInflater.java:680)
          at android.view.LayoutInflater.inflate(LayoutInflater.java:532)
          at android.view.LayoutInflater.inflate(LayoutInflater.java:479)
          at androidx.appcompat.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:696)
          at androidx.appcompat.app.AppCompatActivity.setContentView(AppCompatActivity.java:170)
          at com.example.sevenminutesworkout.BMIActivity.onCreate(BMIActivity.kt:24)
          at android.app.Activity.performCreate(Activity.java:8000)
          at android.app.Activity.performCreate(Activity.java:7984)
          at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1309)
          at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3422)
          at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3601)
          at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:85)
          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:2066)
          at android.os.Handler.dispatchMessage(Handler.java:106)
          at android.os.Looper.loop(Looper.java:223)
          at android.app.ActivityThread.main(ActivityThread.java:7656)
  2021-04-29 16:49:44.824 5682-5682/com.example.sevenminutesworkout E/AndroidRuntime:     at java.lang.reflect.Method.invoke(Native Method)
          at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
          at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)
       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.&lt;init&gt;(TextInputLayout.java:463)
          at com.google.android.material.textfield.TextInputLayout.&lt;init&gt;(TextInputLayout.java:422)
              ... 32 more
  
  </code></pre>
  <p>I've tried to change AppCompat to MaterialComponents but it doesn't work. But when I point to LinearLayout tag (parent of com.google.android.material.textfield.TextInputLayout), it shows the error with a red line, and it disappears when I remove LinearLayout tag away. Is there any problem when I use too many LinearLayout stacks up each other?</p>