Reputation: 567
My app crashes when trying to inflate the com.google.android.material.chip.Chip
class.
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
Upvotes: 1
Views: 2956
Reputation: 73
Put this code in the chip
android:theme="@style/Theme.MaterialComponents.Light"
Upvotes: 2
Reputation: 1693
Use Theme <style name="AppTheme" parent="Theme.MaterialComponents.Light.NoActionBar">
Upvotes: 2
Reputation: 567
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.
Upvotes: 4