Oreo在聚焦TextInputEditText时崩溃

Oreo在聚焦TextInputEditText时崩溃

本文介绍了Android 8.0 Oreo在聚焦TextInputEditText时崩溃的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

将我们的某些设备更新为android 8.0之后,专注于TextInputLayout内的TextInputEditText字段,该应用会由于以下Exception崩溃:

After updating some of our devices to android 8.0 , upon focusing on a TextInputEditText field inside of a TextInputLayout, the app crashes with this Exception:

Fatal Exception: java.lang.NullPointerException: Attempt to invoke virtual method 'void
android.view.View.getBoundsOnScreen(android.graphics.Rect)' on a null object reference
at android.app.assist.AssistStructure$WindowNode.(AssistStructure.java)
at android.app.assist.AssistStructure.(AssistStructure.java)
at android.app.ActivityThread.handleRequestAssistContextExtras(ActivityThread.java:3035)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1807)
at android.os.Handler.dispatchMessage(Handler.java:105)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6541)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)

当我们转到android 设置->系统->语言和输入->高级->自动填充服务->无,然后专注于TextInputEditText / TextInputLayout不再崩溃.

When we go to android Settings -> System -> Languages & input -> Advanced -> Auto-fill service -> None , then focusing on the TextInputEditText / TextInputLayout no longer crashes.

如何在不必禁用设备上新的8.0自动填充服务的情况下防止崩溃发生?

推荐答案

我也遇到了这个问题.事实证明,问题是由在TextInputLayout内嵌套的EditText上设置提示文本引起的.

I ran into this too. It turns out the issue was caused by setting the hint text on the EditText nested inside the TextInputLayout.

我做了一些挖掘,并在26.0.0 Beta 2发行说明中找到了这个块. Android支持发行说明2017年6月

I did some digging and found this nugget in the 26.0.0 Beta 2 release notes.Android Support Release Notes June 2017

这导致我尝试在TextInputLayout而不是嵌套的EditText上设置提示.

That led me to try setting the hint on the TextInputLayout instead of the nested EditText.

这为我解决了崩溃问题.示例:

This resolved the crashing issue for me. Example:

<android.support.design.widget.TextInputLayout
    android:id="@+id/textInputLayout"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:hint="Some Hint Text"
    android.support.design:hintAnimationEnabled="true"
    android.support.design:hintEnabled="true"
    android.support.design:layout_marginTop="16dp">

    <android.support.design.widget.TextInputEditText
        android:id="@+id/editText"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"/>

</android.support.design.widget.TextInputLayout>

我将此作为答案发布在此处当我混合书签时.抱歉,两次发布相同的答案.

I posted this as an answer here as I mixed up bookmarks. Sorry for posting the same answer twice.

这篇关于Android 8.0 Oreo在聚焦TextInputEditText时崩溃的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-30 23:08