Skip to content

Commit e69dfba

Browse files
committed
add android emulator setup to dev workflow
1 parent 4e28afe commit e69dfba

File tree

1 file changed

+69
-0
lines changed

1 file changed

+69
-0
lines changed

development-workflow.md

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,75 @@ title: Development Workflow
1010

1111
- [REFERENCE] https://github.com/NativeScript/docs/blob/master/docs/tooling/android-virtual-devices.md
1212

13+
---
14+
15+
### Android Emulators
16+
17+
Apart from using real Android devices, a viable option is to download, install and use an Android emulator.
18+
In NativeScript, we can use all Android emulators that are connected and recognized by the `ns device` command.
19+
20+
Example output from `ns device`
21+
22+
```
23+
$ ns device
24+
25+
Connected devices & emulators
26+
Searching for devices...
27+
┌───┬─────────────────────────┬──────────┬───────────────────┬──────────┬───────────┐
28+
│ # │ Device Name │ Platform │ Device Identifier │ Type │ Status │
29+
│ 1 │ sdk_google_phone_x86_64 │ Android │ emulator-5554 │ Emulator │ Connected │
30+
│ 2 │ bullhead │ Android │ 00d3e1311075c66f │ Device │ Connected │
31+
└───┴─────────────────────────┴──────────┴───────────────────┴──────────┴───────────┘
32+
```
33+
34+
::: tip Tip
35+
Sometimes emulators take longer to start. As a recommendation and to avoid timing issues, start the emulator before executing other CLI commands. Once the emulator is started, leave it open to avoid the initial load time the next time you need to deploy an Android application.
36+
:::
37+
38+
#### Creating Android Virtual Device via Android Studio
39+
40+
Follow the official documentation on [Creating and Managing Virtual Devices](https://developer.android.com/studio/run/managing-avds.html), where the process of downloading, setting up, and using Android Emulators via Android Studio is covered.
41+
42+
#### Creating Android Virtual Device via command line tool
43+
44+
The `avdmanager` is a tool that allows you to create and manage Android Virtual Devices (AVDs) from the command line. The `avdmanager` is provided in the Android SDK Tools package (25.3.0 and higher) and is located in `<ANDROID_HOME_PATH_HERE>/tools/bin/`. For more information about the avdmanager and how to use it to create AVDs, see the [official avdmanager documentation](https://developer.android.com/studio/command-line/avdmanager.html).
45+
46+
Command syntax to create new AVD
47+
48+
```Shell
49+
$ cd $ANDROID_HOME/tools/bin
50+
$ avdmanager create avd -n name -k "sdk_id" [-c {path|size}] [-f] [-p path]
51+
```
52+
53+
You must provide a name for the AVD and specify the ID of the SDK package to use for the AVD using sdk_id wrapped in quotes.
54+
For example, the following command creates an AVD named `test` using the x86 system image for API level 25:
55+
56+
```Shell
57+
avdmanager create avd -n test -k "system-images;android-29;google_apis;x86"
58+
```
59+
60+
::: warning Note
61+
The above command suggest that the system image is already downloaded. To download an image use the `sdkmanager`. For example `sdkmanager "system-images;android-29;google_apis;x86"`
62+
:::
63+
64+
The following describes the usages for the other options:
65+
-c {path|size}: The path to the SD card image for this AVD or the size of a new SD card image to create for this AVD, in KB or MB, denoted with K or M. For example, -c path/to/sdcard/ or -c 1000M.
66+
-f: Force creation of the AVD. Use this option if you need to overwrite an existing AVD with a new AVD using the same name.
67+
-p path: Path to the ___location where the directory for this AVD's files will be created. If you do not specify a path, the AVD will be created in ~/.android/avd/.
68+
69+
To list all the downloaded system images use the `list` command.
70+
71+
```Shell
72+
avdmanager list
73+
```
74+
75+
## Using third-party emulators
76+
77+
An applicable option is to use third-party emulators (like **GenyMotion**).
78+
Visit the official sites for details on how to install and use these emulators.
79+
80+
- [GenyMotion official site](https://www.genymotion.com)
81+
1382
## Running on physical device
1483

1584
## HMR

0 commit comments

Comments
 (0)