Attempt to invoke interface method on a null object reference finishComposingText() [duplicate]
Asked Answered
D

2

9

I am running robotium on a nexus 6 and getting the following error

 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.reportFinishInputConnection(InputMethodManager.java:859)
 at android.view.ViewRootImpl$ViewRootHandler.handleMessage(ViewRootImpl.java:3253)
 at android.os.Handler.dispatchMessage(Handler.java:102)
 at android.os.Looper.loop(Looper.java:135)
 at android.app.ActivityThread.main(ActivityThread.java:5221)
 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:899)
 at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)

The line in question is:

     solo.enterText((android.widget.EditText) solo.getView("amount"), "11.11");  

I have verified that the field exists, not sure what else could be causing the problem. Any help would be appreciated

Doctor answered 21/1, 2015 at 21:16 Comment(4)
Well, I'd start by extracting the EditText part as a local variable, so you can be sure that you've managed to get it (so it's not a null value) before you pass it to the method...Abreact
solo.getView is returning an instance of the EditTextDoctor
any solutions ? i m running into the same issue...Patricepatrich
Same problem for me, any solutions?Cistercian
B
2

It looks like you getting wrong EditText since you confirmed that returned instance is EditText.

android.widget.EditText editText= (android.widget.EditText)solo.getView("amount");
// validate here that you got right text by any method, for example getText()
solo.enterText(editText, "11.11"); 

and if this one doesn't work you can use direct access without solo:

editText.setText("11.11");
Betrothed answered 12/2, 2016 at 19:47 Comment(1)
im going to accept this. I had issue years ago and can't remember what I did to fix it. Thanks for answeringDoctor
R
8

This 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.

Roulade answered 12/6, 2018 at 8:3 Comment(1)
Not every hero wear capesOsana
B
2

It looks like you getting wrong EditText since you confirmed that returned instance is EditText.

android.widget.EditText editText= (android.widget.EditText)solo.getView("amount");
// validate here that you got right text by any method, for example getText()
solo.enterText(editText, "11.11"); 

and if this one doesn't work you can use direct access without solo:

editText.setText("11.11");
Betrothed answered 12/2, 2016 at 19:47 Comment(1)
im going to accept this. I had issue years ago and can't remember what I did to fix it. Thanks for answeringDoctor

© 2022 - 2024 — McMap. All rights reserved.