24

I am getting this error log on crashlytics. I don't know what makes this crash. It occurs on Android 4.x, 5.x, 6.x devices. (Samsung, Sony, LGE etc.)

Fatal Exception: java.lang.NullPointerException: Attempt to invoke interface method 'boolean android.view.inputmethod.InputConnection.finishComposingText()' on a null object reference
   at android.view.inputmethod.InputConnectionWrapper.finishComposingText(InputConnectionWrapper.java:78)
   at android.view.inputmethod.InputMethodManager.checkFocusNoStartInput(InputMethodManager.java:1809)
   at android.view.inputmethod.InputMethodManager.checkFocus(InputMethodManager.java:1761)
   at android.view.inputmethod.InputMethodManager.isActive(InputMethodManager.java:883)
   at android.widget.Editor$CursorAnchorInfoNotifier.updatePosition(Editor.java:4095)
   at android.widget.Editor$PositionListener.onPreDraw(Editor.java:2564)
   at android.view.ViewTreeObserver.dispatchOnPreDraw(ViewTreeObserver.java:1018)
   at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2313)
   at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1301)
   at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:7021)
   at android.view.Choreographer$CallbackRecord.run(Choreographer.java:777)
   at android.view.Choreographer.doCallbacks(Choreographer.java:590)
   at android.view.Choreographer.doFrame(Choreographer.java:560)
   at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:763)
   at android.os.Handler.handleCallback(Handler.java:739)
   at android.os.Handler.dispatchMessage(Handler.java:95)
   at android.os.Looper.loop(Looper.java:145)
   at android.app.ActivityThread.main(ActivityThread.java:6918)
   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:1404)
   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1199)
1
  • 3
    remove advance profiling
    – Basi
    Apr 20, 2018 at 10:01

5 Answers 5

54

As mentioned here, this can happen because of the Android Advanced Profiling tool.

Disable it from the Run/Debug Configurations dialog:

disabling advanced profiling

5
  • 2
    Any idea why Advanced Profiling is causing this issue?
    – MHogge
    Apr 24, 2018 at 11:47
  • 1
    I'm also curious. How is this connected? May 3, 2018 at 9:15
  • 1
    disabling the option solves the issue but are they gonna provide the proper solution for this? ( Using Android Studio 3.1.3) Jun 20, 2018 at 9:46
  • @AdeelJaved seems like it's fixed in AS 3.2 issuetracker.google.com/issues/77764953
    – Aba
    Jun 22, 2018 at 8:33
  • @Aba thanks yes seems like they have fixed this in AS 3.2 Canary 18 version Jun 26, 2018 at 11:13
11

Make sure the input connection is not null in your onCreateInputConnection override method.

@Override
public InputConnection onCreateInputConnection(EditorInfo outAttrs) {
    InputConnection inputConnection = super.onCreateInputConnection(outAttrs);
    if (inputConnection == null)
    {
        return null;
    }
    return new MyInputConnectionWrapper(inputConnection,
            true);
}

Where MyInputConnectionWrapper is your custom input connection wrapper which is extended from InputConnectionWrapper.

3
  • doesnt this till return null?
    – Jono
    Apr 20, 2018 at 10:28
  • Can you suggest why is this problem occuring? Apr 24, 2018 at 2:17
  • Worked for me, I had a custom class extending AppCompatAutoCompleteTextView, added code in onCreateInputConnection() Thanks a ton!
    – Henu
    Oct 18, 2018 at 11:54
10

It also happened to me because of Advanced Profiling option is enabled.

To disable the advanced profiling, follow these steps:

  1. Select Run > Edit Configurations.
  2. Select your app module in the left pane.
  3. Click the Profiling tab, and then uncheck Enable advanced profiling. Learn more

screenshot

0
2

The above answer should be correct, but in my scenario, the reason for this error is: Edittext is having focus, and this error occurs when edittext.getText() is used. To avoid this error you must:
edittext.gettext().toString(); Note: This edittext must have focus to make this error.

1
  • 1
    Thanks you for posting an answer to this question. The code you posted is not properly marked as code, making it very hard to read and understand. Always take a look at your post in the preview section before posting and check if everything looks OK. Please edit your post until it is easy to read and understand. Also read the article on How to Answer. Well formatted answers will get you more upvotes and have a higher chance of being accepted.
    – lucascaro
    Nov 9, 2018 at 7:39
0

Assume the fragment or Activity have a non EditTextView named mTv; At some appropriate time,mTv.requestFocuse(); This works for me. Hope this helps you.

Your Answer

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

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