提供帮助信息时,TextVew会抛出异常

时间:2017-07-27 03:14:44

标签: android textview google-assistant-sdk

Text从协助请求时抛出NullPointerException。有什么想法有什么不对吗?

我甚至不知道在崩溃时屏幕上到底是什么。

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)

1 个答案:

答案 0 :(得分:6)

我遇到完全相同的错误:

  • 有一个提示集
  • 的textview
  • 当屏幕加载时(或者当我没有接收到自动对焦时点击它),它得到了初始焦点。
  • 在Android O(8.0.0)下。

有一个新的操作系统功能可以自动预填充(并保存)凭据,对于我的情况,当电子邮件地址的文本视图聚焦时,当操作系统尝试显示弹出列表可用选项时,应用程序崩溃了。

我现在的解决方法是:

  • 从XML布局中删除android:hint="...."
  • 添加android:importantForAutofill="no"以关闭自动填充

据我所知,此错误在之前的Android版本中无法重现,因此我猜测这应该是操作系统错误。