Ошибка надувания класса com.google. android .material.textfield.TextInputLayout Android Studio 3.5 - PullRequest
0 голосов
/ 24 января 2020

Я использую android studio 3.5, и это ошибка, которую я получаю для моего TextInputLayout. Макет работал с самого начала, но через некоторое время приложение вылетает с ошибкой

android.view.InflateException: Binary XML file line #18: Binary XML file line #18: Error inflating class com.google.android.material.textfield.TextInputLayout
Caused by: android.view.InflateException: Binary XML file line #18: 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:658)
    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:801)
    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:741)
    at android.view.LayoutInflater.rInflate(LayoutInflater.java:874)
    at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:835)
    at android.view.LayoutInflater.rInflate(LayoutInflater.java:877)
    at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:835)
    at android.view.LayoutInflater.inflate(LayoutInflater.java:515)
    at android.view.LayoutInflater.inflate(LayoutInflater.java:423)

My xml для макета

<com.google.android.material.textfield.TextInputLayout
        style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
        android:layout_width="200dp"
        android:layout_height="wrap_content"
        app:errorEnabled="true"
        app:hintEnabled="true"
        android:theme="@style/TextLabel">


        <com.google.android.material.textfield.TextInputEditText
            android:id="@+id/phone_number"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:ems="15"
            android:hint="@string/phone_number"
            android:inputType="number" />


    </com.google.android.material.textfield.TextInputLayout>

Мои стили. xml is :

<resources>

<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
    <!-- Customize your theme here. -->
    <item name="colorPrimary">@color/colorPrimary</item>
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
    <item name="colorAccent">@color/colorAccent</item>
</style>

<style name="AppTheme.NoActionBar">
    <item name="windowActionBar">false</item>
    <item name="windowNoTitle">true</item>
</style>

<style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" />

<style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" />


<style name="TextLabel" parent="Widget.MaterialComponents.TextInputLayout.FilledBox">

    <item name="colorControlActivated">@color/colorPrimary</item>
</style>

Я также реализовал следующие зависимости, но это не помогло

implementation 'com.google.android.material:material:1.1.0-alpha06'
implementation 'com.google.android.material:material:1.0.0'

Может также быть ошибка с этим новым androidx, как у меня Получали те же ошибки на разных макетах, которые работали бы раньше, а затем через некоторое время приложение снова заработало?

1 Ответ

1 голос
/ 24 января 2020

Тема вашего приложения наследуется от AppCompat, но вы используете компоненты Material. Попробуйте вместо этого изменить тему своего приложения на Theme.MaterialComponents.Light.NoActionBar. Это должно сработать.

...