使用Cordova模拟Android时出现“设备仍在连接”错误

4

我正在尝试安装一个全新的Cordova项目,但是我无法在模拟器上运行它。当我运行cordova emulate android时,它会给我以下错误:

(node:4822) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Failed to execute shell command "getprop,dev.bootcomplete"" on device: Error: adb: Command failed with exit code 1 Error output: error: device still connecting

它确实启动了模拟器,但没有任何反应。我在我的config.xml中添加了这个偏好设置:
<platform name="android">
    <allow-intent href="market:*" />
    <preference name="loadUrlTimeoutValue" value="700000" />
</platform>
2个回答

4

您还有这个问题吗?我也遇到了同样的问题,问题是设备确实仍在连接中。

通过编辑platform/android/cordova/lib/emulator.js文件,在第344行的if语句内或module.exports.wait_for_emulator方法内添加(error.message.indexOf('device still connecting') > -1)即可立即解决此问题,这样进程就不会被终止,只需循环等待直到可以启动adb.shell。

希望对您有所帮助。


这对我有用。谢谢你。你考虑过向cordova-android提交PR吗?在最新版本中似乎没有修复:https://github.com/apache/cordova-android/blob/7.1.x/bin/templates/cordova/lib/emulator.js#L347 - Jon Worek
刚刚提交了一个拉取请求。谢谢提醒。 - rizal

0

尝试启动模拟器(手动启动,或者不要关闭上一次的模拟器),然后再次运行您的命令。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接