Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Binary XML file line #10: Error inflating class com.google.android.material.button.MaterialButton for API Level 19

Implementation 'com.google.android.material: material: 1.0.0'

But I get the error in the header when I run api19 on a device.

For this:

<style name = "Theme.MyApp" parent = "Theme.MaterialComponents.Light">
<style name = "Theme.MyApp" parent = "Theme.MaterialComponents.Light.Bridge">

I tried the methods but did not get a result. How can I solve this?

In other android versions, there is no problem.

<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity">
    <com.google.android.material.button.MaterialButton
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/google_login_button"
        app:icon="@drawable/google"
        app:layout_constraintStart_toStartOf="@+id/guideline"
        app:layout_constraintHorizontal_bias="0.5"
        app:layout_constraintEnd_toStartOf="@+id/facebook_login_button"
        app:layout_constraintHorizontal_chainStyle="spread_inside"
        app:layout_constraintTop_toTopOf="@+id/facebook_login_button"
        app:layout_constraintBottom_toBottomOf="@+id/facebook_login_button"
        android:text="@string/google_button_text" app:cornerRadius="@dimen/login_screen_button_radius"/>

<com.google.android.material.button.MaterialButton
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/facebook_login_button"
        app:icon="@drawable/facebook"
        app:layout_constraintStart_toEndOf="@+id/google_login_button"
        app:layout_constraintHorizontal_bias="0.5"
        app:layout_constraintEnd_toStartOf="@+id/twitter_login_button"
        app:layout_constraintBottom_toBottomOf="parent"
        android:layout_marginBottom="8dp"
        android:text="@string/facebook_button_text" android:layout_marginStart="8dp"
        android:layout_marginEnd="8dp" app:cornerRadius="@dimen/login_screen_button_radius"/>

<com.google.android.material.button.MaterialButton
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/twitter_login_button"
        app:icon="@drawable/twitter"
        app:layout_constraintEnd_toStartOf="@+id/guideline2"
        app:layout_constraintStart_toEndOf="@+id/facebook_login_button"
        app:layout_constraintHorizontal_bias="0.5"
        android:layout_marginEnd="8dp"
        app:layout_constraintBottom_toBottomOf="@+id/facebook_login_button"
        app:layout_constraintTop_toTopOf="@+id/facebook_login_button"
        android:text="@string/twitter_button_text" app:cornerRadius="@dimen/login_screen_button_radius"/>

like image 526
Yavuz Avatar asked Jan 01 '23 11:01

Yavuz


1 Answers

I know its a bit late but for those who will face this problem in future. Change your AppTheme parent to Theme.MaterialComponents

Before

<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
    <!-- Customize your theme here. -->
</style>

After

<!-- Material application theme. -->
<style name="AppTheme" parent="Theme.MaterialComponents.Light.DarkActionBar">
    <!-- Customize your theme here. -->
</style>
like image 180
Nabeel Ahmed Avatar answered Jan 05 '23 17:01

Nabeel Ahmed