question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[MaterialButton] android.view.InflateException:

See original GitHub issue

Description: I’m trying to design a button for my view holder, but the application throws an exception. E/ThemeUtils: View class com.google.android.material.button.MaterialButton is an AppCompat widget that can only be used with a Theme.AppCompat theme (or descendant).

android.view.InflateException: Binary XML file line 149 in

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

Source code:

<com.google.android.material.button.MaterialButton
                    android:id="@+id/call"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_marginTop="24dp"
                    android:layout_marginEnd="12dp"
                    android:onClick="@{()->item.onClickCall()}"
                    android:text="@string/call"
                    android:textColor="@color/colorPrimary"
                    app:backgroundTint="@color/white"
                    app:cornerRadius="6dp"
                    app:icon="@drawable/ic_call"
                    app:iconTint="@color/colorPrimary"
                    app:layout_constraintEnd_toEndOf="parent"
                    app:layout_constraintTop_toBottomOf="@+id/text_view_desc"
                    app:strokeColor="@color/colorPrimary"
                    app:strokeWidth="1dp" />

Android API version: 30

Material Library version: implementation “com.google.android.material:material:1.2.1”

Device: Pixel 2 XL

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:9 (3 by maintainers)

github_iconTop GitHub Comments

3reactions
gabrielemariotticommented, Oct 1, 2020

The ApplicationContext has not the app theme.

0reactions
amjad-alwarehcommented, Oct 1, 2020

Wow, good to know that!!! That means I need the activity/fragment context. Many thanks bro. 😄

Read more comments on GitHub >

github_iconTop Results From Across the Web

Error inflating com.google.android.material.button ... - GitHub
MaterialButton Caused by: android.view.InflateException: Binary XML file line #2: Error inflating class com.google.android.material.button.
Read more >
Using Material Button gives ClassNotFound runtime error
As I have a lot of support elements I had to change the widget in the XML file to "android.support.design.button.MaterialButton" which solved ...
Read more >
MaterialButton - Android Developers
A convenience class for creating a new Material button. This class supplies updated Material styles for the button in the constructor.
Read more >
Error inflating class > com.google.android.material ...
So I use SwitchMaterial in one layout: ... android.view.InflateException: Binary XML file line #324: Binary XML file line #324: Error inflating class ...
Read more >
[Solved]-Binary XML file line #10: Error inflating class com ...
Coding example for the question Binary XML file line #10: Error inflating class com.google.android.material.button.MaterialButton for API Level ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found