I have a monkeyrunner script that connects to an Android device and deploys an APK on it.
serial = '12345JKL'
device = MonkeyRunner.waitForConnection(deviceId=serial)
device.installPackage(path_to_apk)
This works flawlessly when I execute the script using the Windows command shell.
"C:\dev\android\tools\monkeyrunner.bat" "C:\dev\my_script.py" -psome_parameter
The problem is that I want to have my_script.py executed by a TeamCity (Enterprise 6.0.3) build configuration on the same PC: this fails.
Please find the stack trace here: http://pastebin.com/CjWy95c3
First I thought that TC was messing with the parameters of the script. But the command from the TC build log
[00:55:12]: Starting: "C:\dev\android\tools\monkeyrunner.bat" "C:\dev\my_script.py" -psome_parameter
in directory: C:\some_dir
was the same as in the command shell and accordingly the script could connect to the device and worked fine when I copied the command into a command shell while C:\some_dir was my current directory.
I was not able to reproduce this error outside of TC.
I want to emphasize that this all happens on the same PC (Win 7 x64). The script works when executed from the command shell but fails (always when trying to connect to a device) when triggered by the TC build configuration.
I can’t think of a reason why this happens and would be very happy if somebody could point me in the right direction.
Many thanks in advance
Edit: As it turns out the problem isn’t limited to MonkeyRunner.waitForConnection() but also occurs when calling MonkeyRunner.sleep(5). Stacktrace
Can it be that MonkeyRunner and TeamCity don’t go along well with each other?
After a colleague and I have investigated the problem for three days, we could not find the source of this problem. But when we used another machine as the build agent, the issue was gone. We still don’t know what caused this NullPointerException.