2011-04-12 36 views
3

腳本:爲什麼MonkeyRunner.waitForConnection()在我的環境不工作

from com.android.monkeyrunner import MonkeyRunner, MonkeyDevice 
device = MonkeyRunner.waitForConnection(5,'192.168.6.60:5555') 
device.installPackage('Douban_Radio.apk') 

之前運行:

~/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 

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' 

......

後運行:

~/android-sdk-linux_86/tools$adb devices 
adb server is out of date. killing... 
* daemon started successfully * 
List of devices attached 

我只是不知道爲什麼MonkeyRunner.waitForConnection不工作,並殺死的設備亞行連接?請幫助我,非常感謝!

我在本地的env啓動一個AVD,和所連接的設備是:

~/android-sdk-linux_86/tools$adb devices 
List of devices attached 
emulator-5554 device 
192.168.6.60:5555 device 

使用ADB命令是正確的:

~/android-sdk-linux_86/tools$adb -s emulator-5554 install Douban_Radio.apk 
859 KB/s (287518 bytes in 0.326s) 
    pkg: /data/local/tmp/Douban_Radio.apk 
Success 

~/android-sdk-linux_86/tools$adb -s 192.168.6.60:5555 install Douban_Radio.apk 
2108 KB/s (287518 bytes in 0.133s) 
    pkg: /data/local/tmp/Douban_Radio.apk 
Success 

隨着MonkeyRunner。腳本中的waitForConnection

MonkeyRunner.waitForConnection(5,'emulator-5554')工作,
但MonkeyRunner.waitForConnection(5,'192.168.6.60:5555')仍然不起作用。

PS:192.168.6.60是與adb連接的真實設備的ip。

是真實設備的serialNumber錯誤,但爲什麼命令「adb -s 192.168.6.60:5555安裝Douban_Radio.apk」的作品?

回答

3

waitForConnection第二個參數是設備的序列號,在仿真器的情況下'emulator-<port>「:

device = MonkeyRunner.waitForConnection(5,'emulator-5554') 
+0

感謝您的幫助,但問題沒有解決。信息已更新,請看看,非常感謝。 – jobsyang 2011-04-13 07:57:00

+1

使用'emulator-5554'或你的設備有什麼序列號的問題是什麼? – 2011-04-13 15:00:02

5
adb server is out of date. killing... 

我的猜測是,你有你的機器上有多個亞行執行。

當你手動連接,您使用的版本,亞行的支持TCP

Monkeyrunner然後使用不同版本的亞行,就會發現你的現有服務器是過時的(這意味着無論是舊的或新的),並殺死它。然後它會啓動一個不知道你的tcp連接設備的不同版本,因爲你從來沒有告訴它(它可能不是一個支持tcp的版本)。

這將失敗,因爲沒有設備

之後,你檢查,發現ADB服務器過時了,殺了它,開始你的,仍然沒有找到設備...

嘗試查找/ -name「亞行」

,然後運行在他們每個人

亞行版本不要盲目要麼刪除,重命名它,直到你確信你使用的是一個工程。

相關問題