0

No matter what I do, I can not seem to get MonkeyRunner to connect to the emulator, even though it's running and adb shows that it is available:

C:\Users\ADMIN\Documents\android\sdk\platform-tools>adb devices  
List of devices attached  
emulator-5554   device

I am simply trying to use MonkeyRunner through the command line interface to connect to the emulator (which seems to be the most basic thing it can do), but as soon as I try to connect it gives me a NullPointerException:

C:\Users\ADMIN\Documents\android\sdk\tools>monkeyrunner  
Jython 2.5.3 (2.5:c56500f08d34+, Aug 13 2012, 14:54:35)  
[IBM J9 VM (IBM Corporation)] on java1.6.0  
>>> from com.android.monkeyrunner import MonkeyRunner, MonkeyDevice
>>> device = MonkeyRunner.waitForConnection()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
        at com.android.monkeyrunner.JythonUtils.createArgParser(JythonUtils.java:121)
        at com.android.monkeyrunner.MonkeyRunner.waitForConnection(MonkeyRunner.java:64)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:48)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:600)

java.lang.NullPointerException: java.lang.NullPointerException
>>>

Everything that I have been able to find about this NullPointerException is that it happens when trying to run code from within Eclipse, which is not what I am trying to do. I have tried rebooting my machine and even removing the SDK entirely and starting over, and it still doesn't work.

Any ideas on why it's not connecting and giving me an error?

Edit: it looks like all function calls to MonkeyRunner produces the same NullPointerException, even just trying to do "MonkeyRunner.sleep(5)", so I'm thinking there is something wrong with MonkeyRunner itself.

Brian Medendorp
  • 289
  • 2
  • 5

1 Answers1

0

I updated to the latest version of the Java Runtime Environment (JRE), installed the latest version of the Java Development Toolkit (JDK), rebooted my computer and now it seems to work.

I'm not sure if it was the JRE or JDK that finally fixed it, but it must have been missing some Java component somewhere.

Brian Medendorp
  • 289
  • 2
  • 5