我可以使用 Apache Cordova 从 AVD 中选择特定的 Android 设备模拟器吗?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/23777337/
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-08-20 07:25:51  来源:igfitidea点击:

Can I select a particular Android Device Emulator from AVD using Apache Cordova?

androidcordovaandroid-emulatoravd

提问by Ryan Coolwebs

Is there a way when using Cordova CLI to select a particular emulated device from the Android Device Manager (AVD)?

有没有办法使用 Cordova CLI 从 Android 设备管理器 (AVD) 中选择特定的模拟设备?

I am working on a tablet app and a smartphone app at the same time and need to switch to different types of emulators because of the different form factors and screen resolutions?

我正在同时使用平板电脑应用程序和智能手机应用程序,并且由于外形尺寸和屏幕分辨率不同而需要切换到不同类型的模拟器?

I know it's not a particular coding question but perhaps there is some Cordova code I can run in terminal to make the emulation more specific rather than:

我知道这不是一个特定的编码问题,但也许我可以在终端中运行一些 Cordova 代码以使模拟更具体,而不是:

cordova emulate android

Which seems to pick the first emulator off the stack.

这似乎从堆栈中挑选了第一个模拟器。

回答by Keith

Use the targetparameter like this:

target像这样使用参数:

cordova emulate --target=emulator-5554 android

To get the device name of your emulator ("emulator-5554" in this example), run /platforms/android/cordova/lib/list-started-emulators.bat

要获取模拟器的设备名称(在本例中为“emulator-5554”),请运行 /platforms/android/cordova/lib/list-started-emulators.bat

回答by Erti-Chris Eelmaa

For me:

为了我:

If you use OSX, you can open shell in /platforms/android/cordova/lib/ as stated, and write the next command:

如果您使用 OSX,您可以按照说明在 /platforms/android/cordova/lib/ 中打开 shell,然后编写下一个命令:

./list-emulator-images

after you've gotten the emulator image name,

获得模拟器图像名称后,

cordova emulate android --target="the name"

回答by Kelton.Temby

*Moderators rejected my edit and said I should share as answer so -

*版主拒绝了我的编辑并说我应该分享作为答案 -

On Linux (from your project folder) use the command:

在 Linux 上(从您的项目文件夹)使用命令:

/platforms/android/cordova/lib/list-started-emulators

(Note that there's no .batin the command), then look for the console output e.g. emulator-5554. Then as above run:

(请注意,.bat命令中没有 ),然后查找控制台输出,例如emulator-5554. 然后如上运行:

cordova emulate --target=emulator-5554 android