Android 自动填充框架更新8.1导致EditText崩溃

Android 自动填充框架更新8.1导致EditText崩溃,android,android-layout,android-edittext,android-8.0-oreo,android-8.1-oreo,Android,Android Layout,Android Edittext,Android 8.0 Oreo,Android 8.1 Oreo,我将手机从8.0升级到了8.1,现在当我尝试点击我的应用程序上的任何EditText或com.rengwxian.materialedittext.materialedittext(使用API级别25构建)时,我遇到了此崩溃 布局如下: <com.rengwuxian.materialedittext.MaterialEditText android:id="@+id/usernameET" android:

我将手机从8.0升级到了8.1,现在当我尝试点击我的应用程序上的任何EditText或com.rengwxian.materialedittext.materialedittext(使用API级别25构建)时,我遇到了此崩溃

布局如下:

 <com.rengwuxian.materialedittext.MaterialEditText
                    android:id="@+id/usernameET"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_marginBottom="@dimen/padding_xlarge"
                    android:layout_marginTop="@dimen/padding_large"
                    android:enabled="@{!loading}"
                    android:hint="@string/username"
                    android:inputType="text"
                    android:lines="1"
                    android:maxLength="50"
                    android:maxLines="1"
                    android:singleLine="true"
                    android:textSize="@dimen/text_normal"
                    app:met_accentTypeface="fonts/averta_bold.otf"
                    app:met_floatingLabel="highlight"
                    app:met_floatingLabelText="@string/username"
                    app:met_primaryColor="@color/text_dark"
                    app:met_textColor="@color/text_blue"
                    app:met_typeface="fonts/averta_regular.otf" />

你能告诉我为什么会发生这种情况以及我如何解决它吗


提前谢谢你

对我来说似乎是一个简单的回归错误。通过在活动中执行此操作,我采取了最务实的方法。onCreate:

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O_MR1) {
  getWindow().getDecorView().setImportantForAutofill(
      View.IMPORTANT_FOR_AUTOFILL_NO_EXCLUDE_DESCENDANTS);
}

我也有同样的问题。点击Webview中的EditText字段时出现相同错误。 在我的例子中,问题是在attachBaseContext方法中使用了错误的上下文

旧代码

override fun attachBaseContext(newBase: Context?) {
   super.attachBaseContext(applicationContext.createConfigurationContext(...))
}
固定代码:

override fun attachBaseContext(newBase: Context?) {
    super.attachBaseContext(newBase.createConfigurationContext(...))
}

自动填充框架不再出现错误。我建议检查您是否在误用上下文时犯了类似错误。

我花时间研究这个错误:

Fatal Exception: java.lang.NullPointerException: activityToken
       at android.os.Parcel.readException + 2010(Parcel.java:2010)
       at android.os.Parcel.readException + 1950(Parcel.java:1950)
       at android.view.autofill.IAutoFillManager$Stub$Proxy.startSession + 397(IAutoFillManager.java:397)
解决方案:

android:importantForAutofill="no" in XML file in Edit Text.

美好的这解决了我在安卓8.1网络视图上自动填充崩溃的问题。但我仍然不明白为什么会发生这种情况,而且只是在这个特定版本的android中。知道为什么吗?回答得很好!我自己永远也找不到罪犯。碰撞发生的地点与问题开始的地点无关。你为我节省了很多时间!您还可以在xml中添加android:importantForAutofill=“no”,并抑制lint以警告应用更干净的修复:)它对我不起作用
android:importantForAutofill="no" in XML file in Edit Text.