TextVew throws exception when provides info for Assistance
Asked Answered
C

1

5

TextView throws NullPointerException when requested from Assistance. Is there any ideas what's wrong?

I do not even have an idea what exactly was on the screen at the time of the crash.

Fatal Exception: java.lang.NullPointerException: Attempt to invoke virtual method 
'android.graphics.Rect android.graphics.drawable.Drawable.getBounds()' on a null 
object reference
   at android.text.style.DynamicDrawableSpan.getSize(DynamicDrawableSpan.java:78)
   at android.text.MeasuredText.addStyleRun(MeasuredText.java:284)
   at android.text.StaticLayout.generate(StaticLayout.java:744)
   at android.text.DynamicLayout.reflow(DynamicLayout.java:300)
   at android.text.DynamicLayout.<init>(DynamicLayout.java:175)
   at android.widget.TextView.makeSingleLayout(TextView.java:8043)
   at android.widget.TextView.makeNewLayout(TextView.java:7886)
   at android.widget.TextView.assumeLayout(TextView.java:7785)
   at android.widget.TextView.onProvideStructure(TextView.java:10536)
   at android.view.View.dispatchProvideStructure(View.java:7382)
   at android.view.ViewGroup.dispatchProvideStructure(ViewGroup.java:3276)
   at android.view.ViewGroup.dispatchProvideStructure(ViewGroup.java:3276)
   at android.view.ViewGroup.dispatchProvideStructure(ViewGroup.java:3276)
   at android.view.ViewGroup.dispatchProvideStructure(ViewGroup.java:3276)
   at android.view.ViewGroup.dispatchProvideStructure(ViewGroup.java:3276)
   at android.view.ViewGroup.dispatchProvideStructure(ViewGroup.java:3276)
   at android.view.ViewGroup.dispatchProvideStructure(ViewGroup.java:3276)
   at android.view.ViewGroup.dispatchProvideStructure(ViewGroup.java:3276)
   at android.view.ViewGroup.dispatchProvideStructure(ViewGroup.java:3276)
   at android.view.ViewGroup.dispatchProvideStructure(ViewGroup.java:3276)
   at android.view.ViewGroup.dispatchProvideStructure(ViewGroup.java:3276)
   at android.view.ViewGroup.dispatchProvideStructure(ViewGroup.java:3276)
   at android.view.ViewGroup.dispatchProvideStructure(ViewGroup.java:3276)
   at android.app.assist.AssistStructure$WindowNode.<init>(AssistStructure.java:422)
   at android.app.assist.AssistStructure.<init>(AssistStructure.java:1335)
   at android.app.ActivityThread.handleRequestAssistContextExtras(ActivityThread.java:3110)
   at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1834)
   at android.os.Handler.dispatchMessage(Handler.java:102)
   at android.os.Looper.loop(Looper.java:154)
   at android.app.ActivityThread.main(ActivityThread.java:6682)
   at java.lang.reflect.Method.invoke(Method.java)
   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1520)
   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1410)
Cryptoclastic answered 27/7, 2017 at 3:14 Comment(1)
some issue here, and i made the same observations as @Ryan Wong I guess we have to post this into a google groupShowiness
W
6

I have exactly the same error when:

  • there is a textview with hint set
  • It got initial focus when the screen is loaded (or when I click on it if it does not receive automatic focus)
  • under Android O (8.0.0).

There is a new OS feature to automatically prefill (and save) credentials, and for my case when the textview for email address get focused, the App crashed when the OS tries to show a popup listing available options.

My workarounds for now are either:

  • to remove android:hint="...." from the XML layout, or
  • add android:importantForAutofill="no" to turn off auto-fill

This bug is not reproducible on previous Android versions so far as I can see, therefore my speculation is that this should be an OS bug.

Weakkneed answered 17/8, 2017 at 18:7 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.