为什么MonkeyRunner.waitForConnection()没有在我的环境中工作? [英] Why the MonkeyRunner.waitForConnection() doesn't work in my environment?

查看:928
本文介绍了为什么MonkeyRunner.waitForConnection()没有在我的环境中工作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

脚本:

 从com.android.monkeyrunner进口MonkeyRunner,MonkeyDevice
设备= MonkeyRunner.waitForConnection(5,192.168.6.60:5555)
device.installPackage('Douban_Radio.apk')

运行之前:

 〜/ Android的SDK-linux_86 /工具$ ADB连接192.168.6.60:5555
连接到192.168.6.60:5555
〜/ Android的SDK-linux_86 /工具$ ADB设备
设备名单附后
192.168.6.60:5555设备

monkeyrunner的输出:

 〜/ Android的SDK-linux_86 /工具$。/ monkeyrunner monkeyrunnerTest.py
110412 18:12:35.017:S [主] [com.android.monkeyrunner.MonkeyRunnerOptions]由于脚本终止异常
110412 18:12:35.017:S [主] [com.android.monkeyrunner.MonkeyRunnerOptions]回溯(最近通话最后一个):
  文件/home/jobsyang/android-sdk-linux_86/tool​​s/monkeyrunnerTest.py,6号线,上述<&模块GT;
    device.installPackage('Douban_Radio.apk')
AttributeError异常:'NoneType'对象有没有属性'installPackage

......

它运行后:

 〜/ Android的SDK-linux_86 /工具$ ADB设备
ADB服务器已过期。杀...
*守护进程启动成功*
设备名单附后

我只是不知道为什么MonkeyRunner.waitForConnection不工作,并杀死到设备的adb连接?请帮助我,非常感谢!

我启动本地ENV的AVD,并且所连接的设备有:

 〜/ Android的SDK-linux_86 /工具$ ADB设备
设备名单附后
模拟器-5554设备
192.168.6.60:5555设备

使用ADB命令是正确的:

 〜/ Android的SDK-linux_86 /工具$ ADB -s模拟器-5554安装Douban_Radio.apk
859 KB /秒(在0.326s 287518字节)
    PKG:/data/local/tmp/Douban_Radio.apk
成功〜/ Android的SDK-linux_86 /工具$ ADB -s 192.168.6.60:5555安装Douban_Radio.apk
2108 KB /秒(在0.133s 287518字节)
    PKG:/data/local/tmp/Douban_Radio.apk
成功

随着脚本MonkeyRunner.waitForConnection

MonkeyRunner.waitForConnection(5,模拟器-5554)的作品,结果
但MonkeyRunner.waitForConnection(5,192.168.6.60:5555)。还是不行。

PS:192.168.6.60是与亚洲开发银行连接的实际设备的IP

是真正的设备错的serialNumber,但为什么命令亚行-s 192.168.6.60:5555安装Douban_Radio.apk的作品?


解决方案

  ADB服务器是过时的。杀...

我的猜测是,你有你的机器上有多个亚行可执行文件。

当你手动连接,您使用的版本,亚行支持TCP

Monkeyrunner然后使用不同版本的亚行,就会发现你的现有服务器是过时的(这意味着无论是旧或新),并杀死它。然后,它开始不同的版本,不知道您的TCP连接的设备,因为你从来没有告诉它(和它可能不是支持TCP版本)。

这个失败是因为没有设备

之后,你检查,发现亚行服务器过时了,杀了它,你开始了,还是没有找到设备...

尝试查找/ -name亚行

,然后他们每个人运行ADB版本

不要盲目要么删除,重命名它,直到你确信你使用的是一个工程。

Script:

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

Before it runs:

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

The output of 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'

......

After it runs:

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

I just don't know why the MonkeyRunner.waitForConnection doesn't work and kills the adb connection to the device? Please help me, thanks very much!

I start up an AVD in local env, and the connected devices are:

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

Using the adb command is correct:

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

With the MonkeyRunner.waitForConnection in script

MonkeyRunner.waitForConnection(5,'emulator-5554') works,
but MonkeyRunner.waitForConnection(5,'192.168.6.60:5555') still not work.

PS: 192.168.6.60 is the ip of a real device connected with adb.

Is the serialNumber of the real device wrong, but why the command "adb -s 192.168.6.60:5555 install Douban_Radio.apk" works?

解决方案

adb server is out of date. killing...

My guess is that you have more than one adb executable on your machine.

When you manually connect, you are using a version of adb that supports tcp

Monkeyrunner then uses a different version of adb, finds your existing server is out of date (which means either older OR newer) and kills it. It then starts a different version which doesn't know about your tcp connected device since you never told it (and it might not be a version that supports tcp).

This fails because there are no devices

Afterwards, you check, find the adb server out of date, kill it, start yours, and still find no devices...

try a find / -name "adb"

and then run adb version on each of them

Don't blindly delete either, rename it until you are sure you are using one that works.

这篇关于为什么MonkeyRunner.waitForConnection()没有在我的环境中工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆