Home » Android » android – Null Pointer Exception in InputConnection.finishComposingText() method

android – Null Pointer Exception in InputConnection.finishComposingText() method

Posted by: admin May 14, 2020 Leave a comment


I am getting a NPE in inputmethod.InputConnection.finishComposingText(),
The Log message is as follows:

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 com.android.internal.view.IInputConnectionWrapper.executeMessage(IInputConnectionWrapper.java:362)
        at com.android.internal.view.IInputConnectionWrapper$MyHandler.handleMessage(IInputConnectionWrapper.java:78)
        at android.os.Handler.dispatchMessage(Handler.java:102)
        at android.os.Looper.loop(Looper.java:135)
        at android.app.ActivityThread.main(ActivityThread.java:5289)
        at java.lang.reflect.Method.invoke(Native Method)
        at java.lang.reflect.Method.invoke(Method.java:372)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:904)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:699)

I am facing it in Android 5 but works fine in Android .

The error is not specifying any line of code from my code just telling some code lines from library.

I am facing it whenever I press back button to move from one activity to main activity. And yes also other activity contains EditText.

I removed all the instances of softKeyboard, I thought it was due to that

It will be great if someone can help me thanks in advance

How to&Answers:

Go to Edit configuration settings -> Profiling -> Enable advanced profiling
this will prevent EditText from crashing.