首页 > 解决方案 > com.android.support:design:28.0.0 产生错误,因为 Error inflating class TextInputLayout

问题描述

我的应用程序在测试中的所有设备上都可以正常工作,从部署应用程序中,一些大于 SDK 26 的用户收到错误为

膨胀类 TextInputLayout 时出错

我的 build.gradle 文件是

implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support:design:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.google.firebase:firebase-crash:16.2.1'
implementation 'com.android.support:support-v4:28.0.0'
implementation 'com.android.support:support-core-ui:28.0.0'
implementation 'com.android.support:cardview-v7:28.0.0'
implementation 'com.android.support:support-vector-drawable:28.0.0'
implementation 'com.android.support:recyclerview-v7:28.0.0'
implementation 'com.rengwuxian.materialedittext:library:2.1.4'

布局文件是

<com.rengwuxian.materialedittext.MaterialEditText
   android:id="@+id/edt_username"
   android:layout_width="match_parent"
   android:layout_height="wrap_content"
   android:layout_margin="@dimen/dimen_8dp"
   android:drawableStart="@drawable/ic_boy"
   android:drawablePadding="@dimen/dimen_5dp"
   android:hint="@string/usernamehint"
   android:inputType="textNoSuggestions"
   android:textSize="@dimen/dimen_14sp"
   app:met_clearButton="true"
   app:met_floatingLabel="highlight"
   app:met_primaryColor="@color/colorPrimaryDark" />

<android.support.design.widget.TextInputLayout
   android:layout_width="match_parent"
   android:layout_height="wrap_content"
   android:layout_margin="@dimen/dimen_8dp"
   app:passwordToggleEnabled="true"
   app:passwordToggleTint="@color/grey">

  <android.support.design.widget.TextInputEditText
         android:id="@+id/edt_password"
         android:layout_width="match_parent"
         android:layout_height="wrap_content"
         android:drawableStart="@drawable/ic_locked"
         android:drawablePadding="@dimen/dimen_5dp"
         android:gravity="center|start"
         android:hint="@string/password"                                    
         android:inputType="textPassword|textNoSuggestions"
         android:textSize="@dimen/dimen_14sp" />
</android.support.design.widget.TextInputLayout>

我无法找到问题,因为它在测试中运行良好。

请帮我解决这个问题。

标签: androidandroid-textinputlayoutandroid-textinputedittext

解决方案


我建议切换到androidX。可能会解决您的问题

 implementation 'androidx.appcompat:appcompat:1.0.2'
 implementation 'androidx.legacy:legacy-support-v4:1.0.0'

推荐阅读