【问题标题】:Error running emulator on android在android上运行模拟器时出错
【发布时间】:2016-07-23 06:30:02
【问题描述】:

我正在尝试在 android 上运行 phonegap 应用程序,当我运行命令时

phonegap run android --emulator --verbose

我收到了这个错误

Running command "getprop emu.uuid" on emulator-5554...

我该如何解决这个问题,有什么想法吗?我尝试通过命令行和android studio模拟器打开它。

【问题讨论】:

  • 删除 AVD 并重新创建它对我有用。

标签: android cordova android-emulator


【解决方案1】:

我发现如果我在发出运行命令之前手动启动 AVD,则不会出现此错误。我还发现运行旧版本的 android 可以解决这个问题。我不知道这是怎么发生的。运行 Windows 10。

【讨论】:

  • 谢谢,这对我有用。我在 Windows 7 上,当我第一次手动启动 AVD 时,我终于能够在模拟器中看到我的应用程序。
  • 在 Ubuntu 16.04 上也为我工作
【解决方案2】:

我在使用 qemu 的 fedora 23 上使用 cordova 的 Android 6.0 API 级别 23 设备上遇到此错误。

它将运行 cordova emulate android 并且模拟器会显示,但应用程序不会在模拟器中安装或打开。

我的问题是由于cordova 试图通过在adb shell 上轮询getprop emu.uuid 来等待设备准备就绪。

在 adb shell 中运行 getprop emu.uuid 没有产生任何结果。查看getprop 的输出表明可用的属性是dev.bootcomplete

我通过更改platforms/android/cordova/lib/emulator.js 中的以下代码(大约第215-230 行)来修复它以等待dev.bootcomplete 为1 而不是轮询emu.uuid

module.exports.wait_for_emulator = function(uuid) {
        ...
        new_started.forEach(function (emulator) {
            promises.push(
                //Adb.shell(emulator, 'getprop emu.uuid') REMOVE THIS
                Adb.shell(emulator, 'getprop dev.bootcomplete')
                .then(function (output) {
                    //if (output.indexOf(uuid) >= 0) { REMOVE THIS
                    if (output == 1) {
                        emulator_id = emulator;
                    }   
                })  
            );  
        });
   ...

当您同时运行多个模拟器时,这可能会中断。

看来问题出在模拟器上。科尔多瓦运行emulator -avd <device-name> -prop emu.uuid=cordova_emulator_<date>,但emu.uuid 没有在模拟器中正确设置。

希望这对某人有所帮助。

【讨论】:

    最近更新 更多