Android模拟器有时无法启动网络 [英] Android Emulator occasionally fails to start network

查看:146
本文介绍了Android模拟器有时无法启动网络的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

每几次我打开模拟器,它似乎是在离线模式下,对屏幕的顶部,而不是3G的象征,没有明显的网络连通性的X。

Every few times I open the emulator, it will appear to be in offline mode, with the "X" on the top of screen instead of the 3g symbol and no apparent network connectivity.

我已经找到了日志中的唯一明显的区别是:

The only apparent difference in the logs I've found is:

Network works:
12-03 11:24:48.732 D/qemud   (   37): client_fd_receive: attempting registration for service 'gsm'
12-03 11:24:48.732 D/qemud   (   37): client_fd_receive:    -> received channel id 2
12-03 11:24:48.742 D/qemud   (   37): client_registration: registration succeeded for client 2

Network fails:
12-03 03:02:11.688 D/qemud   (   37): client_fd_receive: attempting registration for service 'gsm'
12-03 03:02:11.688 D/qemud   (   37): client_fd_receive:    -> received channel id 2

没有任何人有一个想法,为什么注册不会从一个运行成功到另一个?

Does anybody have an idea why the registration would not succeed from one run to another?

推荐答案

由于这是CI,需要一个临时的解决方法。我们的构建首先运行一个门测试,以检查网络上来没有问题。每次我们的测试中揭开序幕,仿真器创建和测试的网络连接。只有当网络是做了测试运行,否则重新安排了几分钟后(用新的模拟器实例)。虽然这并不prevent的问题,它确实prevent我们的持续集成系统产生假故障。

Since this is for CI, a temporary workaround was needed. Our build first runs a gating test to check that the network came up without issue. Each time our tests kick off, the emulator is created and tested for network connectivity. Only if the network is up do the tests run, otherwise rescheduling for a few minutes later (with a new emulator instance). While this doesn't prevent the problem, it does prevent our continuous integration system from producing false failures.

我测试的网络是否上升的方式是,作为一个单独的作业运行一个小的Groovy脚本:

The way I am testing for if the network is up is with a small groovy script that runs as a separate job:

String status=
   ['sh', '-c', 'adb shell dumpstate | grep -m1 \"Mobile data state: \"'].execute().text.trim();

if (status=="Mobile data state: CONNECTED") {
   System.exit(0);
} else {
   System.exit(1);
}

虽然有可能浪费资源,它打败间歇性故障的电子邮件的替代品。

While potentially wasteful of resources, it beats the alternative of intermittent failure emails.

这篇关于Android模拟器有时无法启动网络的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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