首页 > 解决方案 > 无法在模拟器上运行离子应用程序

问题描述

我正在尝试在 android 模拟器上运行 ionic 应用程序,但我不断收到此错误。

    ANDROID_HOME=C:\Users\Dell\AppData\Local\Android\sdk
    JAVA_HOME=C:\Program Files\Java\jdk1.8.0_171
    (node:14376) UnhandledPromiseRejectionWarning: Error: C:\Users\Dell\AppData\Local\Android\sdk\platform-tools\adb.exe: Command failed with exit code 1 Error output:
adb server version (39) doesn't match this client (40); killing...
could not read ok from ADB Server
* failed to start daemon
error: cannot connect to daemon
    at ChildProcess.whenDone (C:\Users\Dell\Desktop\ionicsidemenu\ionic2-sidemenu-highlight\platforms\android\cordova\node_modules\cordova-common\src\superspawn.js:169:23)
    at ChildProcess.emit (events.js:180:13)
    at maybeClose (internal/child_process.js:936:16)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:220:5)
(node:14376) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:14376) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

标签: androidnode.jsionic3

解决方案


这种不一致场景的可能解决方案如下:

  1. 在 android 平台下的 config.xml 中添加此首选项:

<preference name="loadUrlTimeoutValue" value="700000" />

  1. 每次启动前杀死并重新启动 adb 服务器

adb kill-server adb forward --remove-all adb start-server

  1. 尝试创建一个新的 AVD 并将其作为目标,同时启动 AVD 删除并重新添加 android 平台并重建相同

推荐阅读