脚本:
from com.android.monkeyrunner import MonkeyRunner, MonkeyDevice
device = MonkeyRunner.waitForConnection(5,'192.168.6.60:5555')
device.installPackage('Douban_Radio.apk')
Run Code Online (Sandbox Code Playgroud)
在它运行之前:
~/android-sdk-linux_86/tools$adb connect 192.168.6.60:5555
connected to 192.168.6.60:5555
~/android-sdk-linux_86/tools$adb devices
List of devices attached
192.168.6.60:5555 device
Run Code Online (Sandbox Code Playgroud)
monkeyrunner的输出:
~/android-sdk-linux_86/tools$./monkeyrunner monkeyrunnerTest.py
110412 18:12:35.017:S [main] [com.android.monkeyrunner.MonkeyRunnerOptions] Script terminated due to an exception
110412 18:12:35.017:S [main] [com.android.monkeyrunner.MonkeyRunnerOptions]Traceback (most recent call last):
File "/home/jobsyang/android-sdk-linux_86/tools/monkeyrunnerTest.py", line 6, in <module>
device.installPackage('Douban_Radio.apk')
AttributeError: 'NoneType' object has no attribute 'installPackage'
Run Code Online (Sandbox Code Playgroud)
......
运行后:
~/android-sdk-linux_86/tools$adb devices
adb server is out of date. killing...
* daemon started successfully *
List of devices attached …Run Code Online (Sandbox Code Playgroud)