2017-06-12 55 views
1
java.lang.NullPointerException: 
    at android.widget.Editor.updateFloatingToolbarVisibility(Editor.java:1541) 
    at android.widget.Editor.onTouchEvent(Editor.java:1491) 
    at android.widget.TextView.onTouchEvent(TextView.java:10025) 
    at android.view.View.dispatchTouchEvent(View.java:10723) 
    at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2865) 
    at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2550) 
    at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2865) 
    at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2550) 
    at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2865) 
    at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2550) 
    at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2865) 
    at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2550) 
    at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2865) 
    at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2550) 
    at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2865) 
    at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2550) 
    at com.android.internal.policy.DecorView.superDispatchTouchEvent(DecorView.java:559) 
    at com.android.internal.policy.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1870) 
    at android.app.Activity.dispatchTouchEvent(Activity.java:3236) 
    at com.android.internal.policy.DecorView.dispatchTouchEvent(DecorView.java:521) 
    at android.view.View.dispatchPointerEvent(View.java:10952) 
    at android.view.ViewRootImpl$ViewPostImeInputStage.processPointerEvent(ViewRootImpl.java:5117) 
    at android.view.ViewRootImpl$ViewPostImeInputStage.onProcess(ViewRootImpl.java:4969) 
    at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:4500) 
    at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:4553) 
    at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:4519) 
    at android.view.ViewRootImpl$AsyncInputStage.forward(ViewRootImpl.java:4652) 
    at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:4527) 
    at android.view.ViewRootImpl$AsyncInputStage.apply(ViewRootImpl.java:4709) 
    at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:4500) 
    at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:4553) 
    at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:4519) 
    at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:4527) 
    at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:4500) 
    at android.view.ViewRootImpl.deliverInputEvent(ViewRootImpl.java:7007) 
    at android.view.ViewRootImpl.doProcessInputEvents(ViewRootImpl.java:6936) 
    at android.view.ViewRootImpl.enqueueInputEvent(ViewRootImpl.java:6897) 
    at android.view.ViewRootImpl$WindowInputEventReceiver.onInputEvent(ViewRootImpl.java:7117) 
    at android.view.InputEventReceiver.dispatchInputEvent(InputEventReceiver.java:185) 
    at android.view.InputEventReceiver.nativeConsumeBatchedInputEvents(Native Method:0) 
    at android.view.InputEventReceiver.consumeBatchedInputEvents(InputEventReceiver.java:176) 
    at android.view.ViewRootImpl.doConsumeBatchedInput(ViewRootImpl.java:7081) 
    at android.view.ViewRootImpl$ConsumeBatchedInputRunnable.run(ViewRootImpl.java:7144) 
    at android.view.Choreographer$CallbackRecord.run(Choreographer.java:927) 
    at android.view.Choreographer.doCallbacks(Choreographer.java:702) 
    at android.view.Choreographer.doFrame(Choreographer.java:632) 
    at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:913) 
    at android.os.Handler.handleCallback(Handler.java:751) 
    at android.os.Handler.dispatchMessage(Handler.java:95) 
    at android.os.Looper.loop(Looper.java:154) 
    at android.app.ActivityThread.main(ActivityThread.java:6682) 
    at java.lang.reflect.Method.invoke(Native Method:0) 
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1520) 
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1410) 

這不是重複的帖子。java.lang.NullPointerException:at android.widget.Editor.updateFloatingToolbarVisibility

用戶報告過這個問題,但我不知道如何重現並修復它。它發生在Android N三星設備上。

我的猜測是發生在EditText中。

有任何建議。

+0

有關此問題的任何想法。 – RameshJaga

+1

@Rameshbabu在這裏找到類似的問題https://stackoverflow.com/questions/42926522/java-lang-nullpointerexception-with-nougat –

+0

@Rameshbabu我無法重現這個問題。你能幫我嗎? –

回答

-1

空指針異常幾乎總是因爲元素在嘗試引用它之前未在代碼中正確初始化。 例如請確保TextView對象在嘗試使用之前存在:

TextView myTextView = new TextView(); 
+0

沒有這樣的對象。我不知道它爲什麼出現在日誌中。 –

+0

顯然它是TextView窗口類的一個幫助對象https://android.googlesource.com/platform/frameworks/base/+/jb-release/core/java/android/widget/Editor.java。所以可能你的TextView實例需要在嘗試訪問它之前實例化。 – landonmutch