18

My app has been humming along nicely through various Android versions. I have users running it on Android 4.3, 5.0, 5.1 and 6.0 with no problems. However a user with a S7 Edge has just updated with Android 7.0 and the app is crashing when text is pasted into an EditText field (This is the first and only thing you do with this app - it starts you paste in text into a box and then the app parses the text).

I have looked at many threads on Null Pointer Exceptions and I have looked at the source for Editor.java but nothing is obvious. The stack trace below shows no problems with my code. Any ideas what they changed with 7.0 that could be causing this?

java.lang.NullPointerException: Attempt to invoke virtual method 'boolean android.widget.Editor$SelectionModifierCursorController.isDragAcceleratorActive()' on a null object reference
at android.widget.Editor.updateFloatingToolbarVisibility(Editor.java:1520)
at android.widget.Editor.onTouchEvent(Editor.java:1475)
at android.widget.TextView.onTouchEvent(TextView.java:10024)
at android.view.View.dispatchTouchEvent(View.java:10725)
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.widget.ScrollView.dispatchTouchEvent(ScrollView.java:738)
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:505)
at com.android.internal.policy.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1863)
at android.app.Activity.dispatchTouchEvent(Activity.java:3226)
at com.android.internal.policy.DecorView.dispatchTouchEvent(DecorView.java:467)
at android.view.View.dispatchPointerEvent(View.java:10954)
at android.view.ViewRootImpl$ViewPostImeInputStage.processPointerEvent(ViewRootImpl.java:5051)
at android.view.ViewRootImpl$ViewPostImeInputStage.onProcess(ViewRootImpl.java:4908)
at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:4439)
at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:4492)
at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:4458)
at android.view.ViewRootImpl$AsyncInputStage.forward(ViewRootImpl.java:4591)
at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:4466)
at android.view.ViewRootImpl$AsyncInputStage.apply(ViewRootImpl.java:4648)
at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:4439)
at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:4492)
at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:4458)
at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:4466)
at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:4439)
at android.view.ViewRootImpl.deliverInputEvent(ViewRootImpl.java:6936)
at android.view.ViewRootImpl.doProcessInputEvents(ViewRootImpl.java:6875)
at android.view.ViewRootImpl.enqueueInputEvent(ViewRootImpl.java:6836)
at android.view.ViewRootImpl$WindowInputEventReceiver.onInputEvent(ViewRootImpl.java:7046)
at android.view.InputEventReceiver.dispatchInputEvent(InputEventReceiver.java:185)
at android.view.InputEventReceiver.nativeConsumeBatchedInputEvents(Native Method)
at android.view.InputEventReceiver.consumeBatchedInputEvents(InputEventReceiver.java:176)
at android.view.ViewRootImpl.doConsumeBatchedInput(ViewRootImpl.java:7010)
at android.view.ViewRootImpl$ConsumeBatchedInputRunnable.run(ViewRootImpl.java:7073)
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:6688)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1468)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1358)
10
  • 2
    Looks like it is a known issue: code.google.com/p/android/issues/detail?id=228485 Mar 21, 2017 at 12:10
  • Not exactly the same method crashing but that is partially helpful in that it isnt my app. However I would like to know how to get around it. As I said though my app isn't doing anything when they paste the text in :-(
    – Gavin
    Mar 21, 2017 at 12:19
  • @Gavin: The cited bug and your crash are coming from Samsung devices. Can you reproduce your problem in the emulator, or in a non-Samsung Android 7.0+ environment? Mar 22, 2017 at 11:38
  • @CommonsWare I haven't had a chance to properly experiment in the emulator. I do see some other users are on Android 7 in the dashboard but I only have one user experiencing this problem at the moment and they advise the problem started after upgrading to Nougat.
    – Gavin
    Mar 25, 2017 at 9:50

3 Answers 3

7

I resolved it by removing

MyEditText.setMovementMethod(new ScrollingMovementMethod());

1
  • 2
    thanks. I was using it for scrolling and this solution works for me.
    – Awais
    Feb 7, 2018 at 13:38
5

This is how you block the copy paste menu from appearing in any way, shape or form. This bug really drove me crazy, and as with any Samsung bug you know its in their code but you also know they won't fix it any time soon. Anyways, here's wonder wall...

  1. Check if Android.Build.Model.toLowerCase().startsWith('sm-g930'). Do not match the whole string, the last letter is a minor version identifier. I stored this boolean in shouldBlockCopyPaste variable which comes up later.

  2. If it matches you want to block the copy paste menu from showing. This is how you ACTUALLY DO IT!!!

Override these 2 functions, you'll notice my shouldBlockCopyPaste boolean, this is so other devices dont get blocked.

   @Override
   public ActionMode StartActionMode (ActionMode.Callback callback){
      if (shouldBlockCopyPaste) {
        return null;
      } else {
        return super.StartActionMode(callback);
      }
    }

   @Override
   public ActionMode StartActionMode (ActionMode.Callback callback, int type){
      if (shouldBlockCopyPaste) {
        return null;
      } else {
        return super.StartActionMode(callback, type);
      }
    }
1
  • This solution didn't work. Did it work with you ? Do you have any other proposed solutions ? Jun 7, 2017 at 14:24
0

I've seen this crash for a while in my app coming from Samsung devices. turned out that a long press on a TextView brought up the copy-paste menu on those devices and the user was even able to paste text over (although its not an EditText component). Ended up disabling all types of interactions in the XML of the culprit TextViews (most importantly longClickable) and the crash wen't away.

 <TextView
...
    android:longClickable="false"
    android:clickable="false"
    android:linksClickable="false" />
1
  • A user just reported to me that following the Oreo update on his S8 that this problem has disappeared. FYI.
    – Gavin
    Apr 18, 2018 at 10:29

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.