1

My app crashes when trying to inflate the com.google.android.material.chip.Chipclass.

The dependency i am using is implementation 'com.google.android.material:material:1.0.0'

Here is my XML code

 <com.google.android.material.chip.Chip
        android:id="@+id/chipActive"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        app:chipCornerRadius="5dp"
        android:backgroundTint="@color/primaryColor"
        android:textColor="@color/primaryTextColor"
        android:textAlignment="center"
        android:fontFamily="@font/roboto_regular"
        android:layout_marginStart="10dp"
        android:text="Active"/>

The error I get is

 android.view.InflateException: Binary XML file line #18: Binary XML file line #18: Error inflating class com.google.android.material.chip.Chip
    at android.view.LayoutInflater.inflate(LayoutInflater.java:551)
    at android.view.LayoutInflater.inflate(LayoutInflater.java:429)

I found a question similar to mine on another thread but there was no solution there that was helpful to me. If anyone has any suggestions on how to fix this issue please help me :D

pavlos
  • 547
  • 1
  • 9
  • 23

3 Answers3

4

I found the solution just after posting this question. I updated the dependency to implementation 'com.google.android.material:material:1.1.0-alpha02' and now it works fine.

pavlos
  • 547
  • 1
  • 9
  • 23
2

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

Arul Pandian
  • 1,685
  • 15
  • 20
2

Put this code in the chip

android:theme="@style/Theme.MaterialComponents.Light"