java.lang.NullPointerException:尝试调用虚方法' void android.widget.Editor $ SelectionModifierCursorController.show()'

时间:2016-06-22 20:51:08

标签: android android-support-library

我在Crashlytics上有一个例外,它没有在堆栈跟踪中显示我的任何代码,我怎样才能弄清楚导致它的原因?似乎只在Android 5.0和5.0.1上发生。我正在使用支持库23.4。

Fatal Exception: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.widget.Editor$SelectionModifierCursorController.show()' on a null object reference
       at android.widget.Editor$SelectionActionModeCallback.onCreateActionMode(Editor.java:3023)
       at com.android.internal.policy.impl.PhoneWindow$DecorView$ActionModeCallbackWrapper.onCreateActionMode(PhoneWindow.java:3163)
       at android.support.v7.view.SupportActionModeWrapper$CallbackWrapper.onCreateActionMode(SupportActionModeWrapper.java:155)
       at android.support.v7.app.AppCompatDelegateImplV7$ActionModeCallbackWrapperV7.onCreateActionMode(AppCompatDelegateImplV7.java:1742)
       at android.support.v7.app.AppCompatDelegateImplV7.startSupportActionModeFromWindow(AppCompatDelegateImplV7.java:802)
       at android.support.v7.app.AppCompatDelegateImplV7.startSupportActionMode(AppCompatDelegateImplV7.java:696)
       at android.support.v7.app.AppCompatDelegateImplV14$AppCompatWindowCallbackV14.startAsSupportActionMode(AppCompatDelegateImplV14.java:187)
       at android.support.v7.app.AppCompatDelegateImplV14$AppCompatWindowCallbackV14.onWindowStartingActionMode(AppCompatDelegateImplV14.java:171)
       at android.support.v7.view.WindowCallbackWrapper.onWindowStartingActionMode(WindowCallbackWrapper.java:145)
       at com.android.internal.policy.impl.PhoneWindow$DecorView.startActionMode(PhoneWindow.java:2644)
       at com.android.internal.policy.impl.PhoneWindow$DecorView.startActionModeForChild(PhoneWindow.java:2631)
       at android.view.ViewGroup.startActionModeForChild(ViewGroup.java:694)
       at android.view.ViewGroup.startActionModeForChild(ViewGroup.java:694)
       at android.view.ViewGroup.startActionModeForChild(ViewGroup.java:694)
       at android.view.ViewGroup.startActionModeForChild(ViewGroup.java:694)
       at android.view.ViewGroup.startActionModeForChild(ViewGroup.java:694)
       at android.view.ViewGroup.startActionModeForChild(ViewGroup.java:694)
       at android.view.ViewGroup.startActionModeForChild(ViewGroup.java:694)
       at android.view.ViewGroup.startActionModeForChild(ViewGroup.java:694)
       at android.view.ViewGroup.startActionModeForChild(ViewGroup.java:694)
       at android.view.ViewGroup.startActionModeForChild(ViewGroup.java:694)
       at android.view.ViewGroup.startActionModeForChild(ViewGroup.java:694)
       at android.view.ViewGroup.startActionModeForChild(ViewGroup.java:694)
       at android.view.ViewGroup.startActionModeForChild(ViewGroup.java:694)
       at android.view.ViewGroup.startActionModeForChild(ViewGroup.java:694)
       at android.view.View.startActionMode(View.java:4857)
       at android.widget.Editor.startSelectionActionMode(Editor.java:1626)
       at android.widget.Editor.performLongClick(Editor.java:914)
       at android.widget.TextView.performLongClick(TextView.java:8900)
       at android.view.View$CheckForLongPress.run(View.java:19735)
       at android.os.Handler.handleCallback(Handler.java:739)
       at android.os.Handler.dispatchMessage(Handler.java:95)
       at android.os.Looper.loop(Looper.java:135)
       at android.app.ActivityThread.main(ActivityThread.java:5253)
       at java.lang.reflect.Method.invoke(Method.java)
       at java.lang.reflect.Method.invoke(Method.java:372)
       at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)

EDIT1:报告崩溃的用户想出了如何重现它。当他使用我的AppCompatAutoCompleteTextView选择所有文本并将其复制到剪贴板时,就会发生这种情况。它只发生在Android 5.0和5.0.1

EDIT2:我认为它不仅仅发生在Android 5上,而且堆栈跟踪看起来不同,Crashlytics并没有对它进行分组。基于一些帖子,我发现我认为它与Contextual Actionbar高度或它如何计算它有关但我还没有找到一个明确的答案。

2 个答案:

答案 0 :(得分:2)

我有一个AppCompatAutoCompleteTextView,当它处于焦点时会改变大小。结果是用户在折叠大小时长按它并且当onFocusChange事件被触发时整个事情会发生变化并且会崩溃。

答案 1 :(得分:2)

您可以通过在setText("test");内调用onFocusChange并在三星s8上长按该EditText来重现(我不确定其他设备)。

作为解决方案,您可以尝试摆脱设置文本或其他导致onFocusChange中的文本重新排列或使用处理程序延迟文本的其他操作。