Closed Fatme closed 6 years ago
I've tried this code and I have issues with Genymotion emulators - I do not have paths to Genymotion executables in my PATH, so my expectation was that the emulators will not be available. However, tns devices --available-devices
listed my Genymotion emulators.
$ ./bin/tns devices --available-devices
Available emulators
┌─────────────┬──────────┬────────────┬──────────────────────────────────────┐
│ Device Name │ Platform │ Version │ Device Identifier │
│ Nexus 6 │ Android │ android-24 │ GN6 │
│ Nexus 5X │ Android │ android-26 │ Nexus_5X_API_26_x86 │
│ GN5X_API24 │ Android │ 7.0 │ daa35603-f7ca-46a4-90f5-1116e8cd187d │
└─────────────┴──────────┴────────────┴──────────────────────────────────────┘
Connected devices & emulators
Searching for devices...
iTunes is not installed. Install it on your system and run this command again.
Cannot find connected devices. Reconnect any connected devices, verify that your system recognizes them, and run this command again.
I've tried running my app on one of them by passing the name:
$ ../../bin/tns run android --device GN5X_API24
Searching for devices...
Cannot find connected devices.
Emulator start failed with: No emulator image available for emulator 'GN5X_API24'.
To list currently connected devices and verify that the specified identifier exists, run 'tns device'.
To list available emulator images, run 'tns device <Platform> --available-devices'.
After that I've tried with the identifier:
$ ../../bin/tns run android --device daa35603-f7ca-46a4-90f5-1116e8cd187d
Searching for devices...
Error: spawn player ENOENT
at _errnoException (util.js:992:11)
at Process.ChildProcess._handle.onexit (internal/child_process.js:190:19)
at onErrorNT (internal/child_process.js:372:16)
at _combinedTickCallback (internal/process/next_tick.js:138:11)
at process._tickCallback (internal/process/next_tick.js:180:9)
Also I'm unable to run my normal emulator via its name (not sure if this is supported):
$ ../../bin/tns run android --device "Nexus 5X"
Searching for devices...
Cannot find connected devices.
Emulator start failed with: No emulator image available for emulator 'Nexus 5X'.
To list currently connected devices and verify that the specified identifier exists, run 'tns device'.
To list available emulator images, run 'tns device <Platform> --available-devices'.
When passing the identifier, emulator starts, but CLI hangs and after some time, it fails with error:
Emulator start failed with: Cannot run your app in the native emulator. Increase the timeout of the operation with the --timeout option or try to restart your adb server with 'adb kill-server' command. Alternatively, run the Android Virtual Device manager and increase the allocated RAM for the virtual device.
After that, I execute the same command (note - the emulator is already running) and the operation fails with different error:
$ ../../bin/tns run android --device "Nexus_5X_API_26_x86"
Searching for devices...
Waiting for emulator device initialization...
Could not find device by specified identifier 'Nexus_5X_API_26_x86'. To list currently connected devices and verify that the specified identifier exists, run 'tns device'.
In fact, tns device
shows the following:
rosen@DESKTOP-A5EQ3J3 MINGW64 /d/Rosen/Work/nativescript-cli/scratch/app13 (fatme/emulator-api)
$ ../../bin/tns device
Connected devices & emulators
Searching for devices...
iTunes is not installed. Install it on your system and run this command again.
┌───┬────────────────┬──────────┬───────────────────┬──────────┬───────────┐
│ # │ Device Name │ Platform │ Device Identifier │ Type │ Status │
│ 1 │ sdk_gphone_x86 │ Android │ emulator-5554 │ Emulator │ Connected │
└───┴────────────────┴──────────┴───────────────────┴──────────┴───────────┘
The strange thing is that the name I see for my image is: Nexus 5X API 26 x86
, not Nexus_5X_API_26_x86
: https://www.screencast.com/t/KjXdsy3jYu
Also it looks like it tried to start additional emulator from the same image.
This PR deletes all legacy, unneeded and duplicated code that is used for working with iOS and Android emulators.
This PR adds the functionalities below:
tns devices android --available-devices
- shows all available Android genymotion and Android avd emulators (previously only avd emulators were shown)tns devices --available-devices
- works correctly and shows all available iOS simulators, Android genymotion and Android avd emulators. (previously does not work)tns run android --device <imageIdentifier>
- it is already possible to run on device with specified imageIdentifier (previously it can run only on emulators specified by identifier or name)This PR exposes emulator api from devicesService. The api consists from the following two methods:
Each available android emulator (NOTE: not running emulator) has the properties below:
Each running android emulator has the properties below:
--timeout
option. This option describes the timeout in miliseconds that {N} CLI will wait emulator boot to complete. It might take too long time on some machines to start native android emulator, so this option is useful in such cases.