node.js 让 Cordova/Phonegap 在 Genymotion 虚拟设备上进行模拟

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/20544020/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-02 16:29:53  来源:igfitidea点击:

Getting Cordova/Phonegap to emulate on Genymotion virtual device

node.jscordovaandroid-emulatornpmgenymotion

提问by numediaweb

Using the Cordova CLI, I set up an app and build it:

使用 Cordova CLI,我设置并构建了一个应用程序:

cordova create hi com.example.hi Hi 
cd hi
cordova platform add android
cordova build android

I run Genymotion and start a device named "api9". I run the Android Debug Bridge adb devicesand it shows as

我运行 Genymotion 并启动一个名为“api9”的设备。我运行 Android 调试桥adb devices,它显示为

192.168.8.101:5555

I try to launch the app with cordova emulate androidbut I get:

我尝试启动应用程序,cordova emulate android但我得到:

Error: An error occurred while emulating/deploying the android project. ...spawn ENOENT

However, launching the Android Virtual Device manager and starting an emulated device; the cordova emulate androidworks and adb deviceslists;

但是,启动 Android 虚拟设备管理器并启动模拟设备;该cordova emulate android作品和adb devices名单;

192.168.8.101:5555
emulator-5554

What should I do to make Cordova emulate through Genymotion devices?

我应该怎么做才能让 Cordova 通过 Genymotion 设备进行模拟?

回答by Nextneed

It seems that adbsees genymotion virtual device as a real device and not as an emulated one, try cordova run androidinstead of cordova emulate android.

似乎adb将 genymotion 虚拟设备视为真实设备而不是模拟设备,尝试cordova run android代替cordova emulate android.

回答by Harald Doderer

When the device list is empty, which is not covered in this case, then you need to connect adb manually to the genymotion device.

当设备列表为空时,本例不涉及,则需要手动连接adb到genymotion设备。

Therefore you have it run in the same JAVA SDK environment so don't use the inbuilt one in Genymotion.

因此,您让它在相同的 JAVA SDK 环境中运行,所以不要使用 Genymotion 中的内置环境。

Then start up your device. On screen should appear some genymotion icon. Click it and you will see the IP.

然后启动您的设备。屏幕上应该会出现一些 genymotion 图标。单击它,您将看到IP。

Use then in the console the command "adb connect 198.123.123.123" (use your own IP of course).

然后在控制台中使用命令“adb connect 198.123.123.123”(当然使用您自己的IP)。

After that your device list is updated.

之后,您的设备列表将更新。

Finally use "cordova run android" and it will install your app to the virtual device.

最后使用“cordova run android”,它会将您的应用程序安装到虚拟设备。

Same applies also for ionic framework: "ionic run android". Caution: without any device found it will fallback to emulator...

同样适用于 ionic 框架:“ionic run android”。注意:如果没有找到任何设备,它将回退到模拟器......