LoginSignup
15
7

More than 5 years have passed since last update.

Android 8 (Oreo) の EditText をタップするとクラッシュする

Posted at

現象

Android 8.0.0 (Oreo) でかつ Support Library 26.x.x を使用しているときに EditText をタップするとクラッシュするようだ。

  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.<init>(AssistStructure.java:486)
    at android.app.assist.AssistStructure.<init>(AssistStructure.java:1912)
    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(Native Method)
    at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)

AOSP の issue にもなっていて、fixed になっているので、恐らく 8.0.1 で直るものだと思われる。

ワークアラウンド

Widget.AppCompat.EditText の style を上書きしてしまうのが楽ならしい。

<style name="MyTheme" parent="@style/Nanika">
  ...
  <item name="editTextStyle">@style/EditTextStyle</item>
  ...
</style>

<style name="EditTextStyle" parent="@style/Widget.AppCompat.EditText">
  <item name="android:importantForAutofill" tools:ignore="NewApi">noExcludeDescendants</item>
</style>

参考文献

15
7
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
15
7