我有一个TextInputLayout包装的TextInputEditText。然而,在某些键盘上,当用户有拼写建议并点击单词以显示建议弹出列表时,我的应用程序会崩溃,留下键盘在屏幕上,有时会覆盖对话框。
这种情况发生在Android 6、7和8上。我可以使用三星Galaxy S5运行6.0.1和股票三星键盘复制问题,但在同一设备上不使用Gboard或Swype,以及在运行默认Google键盘的Nexus 5x上。
该应用程序目标为26,并使用设计支持库版本26.1.0。我们在几个支持库版本中都遇到了相同的堆栈跟踪,而且此问题或类似问题已被修复。
很难找到原因并复制它。我没有设置任何特殊的主题或颜色 - 只是appcompat。以下是堆栈跟踪:
这种情况发生在Android 6、7和8上。我可以使用三星Galaxy S5运行6.0.1和股票三星键盘复制问题,但在同一设备上不使用Gboard或Swype,以及在运行默认Google键盘的Nexus 5x上。
该应用程序目标为26,并使用设计支持库版本26.1.0。我们在几个支持库版本中都遇到了相同的堆栈跟踪,而且此问题或类似问题已被修复。
很难找到原因并复制它。我没有设置任何特殊的主题或颜色 - 只是appcompat。以下是堆栈跟踪:
java.lang.UnsupportedOperationException: Failed to resolve attribute at index 6: TypedValue{t=0x2/d=0x101009b a=1}
at android.content.res.TypedArray.getColorStateList(TypedArray.java:484)
at android.text.style.TextAppearanceSpan.<init>(TextAppearanceSpan.java:65)
at android.text.style.TextAppearanceSpan.<init>(TextAppearanceSpan.java:45)
at android.widget.Editor$SuggestionsPopupWindow$SuggestionInfo.<init>(Editor.java:3012)
at android.widget.Editor$SuggestionsPopupWindow$SuggestionInfo.<init>(Editor.java:3007)
at android.widget.Editor$SuggestionsPopupWindow.initContentView(Editor.java:2995)
at android.widget.Editor$PinnedPopupWindow.<init>(Editor.java:2844)
at android.widget.Editor$SuggestionsPopupWindow.<init>(Editor.java:2969)
at android.widget.Editor.showSuggestions(Editor.java:2229)
at android.widget.Editor$2.run(Editor.java:2109)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:158)
at android.app.ActivityThread.main(ActivityThread.java:7224)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)
以下是我找到的类似/相关问题:
- Android N中TextAppearanceSpan导致崩溃
- Fatal Exception: java.lang.UnsupportedOperationException: 无法解析索引为6的属性:TypedValue{t=0x2/d=0x101009b a=1}
- https://meta.stackexchange.com/questions/292199/点击拼写检查器下划线红色文本时,Android应用程序崩溃
不幸的是,目前看来唯一的解决方法是禁用所有用户在TextInputEditText字段上的拼写建议,这相当糟糕。如果有其他想法/建议,请告诉我。