DEV Community

loading...
Cover image for Launching Angular app on emulator without Android Studio

Launching Angular app on emulator without Android Studio

koscheyscrag profile image Andrei Fedotov Updated on ・2 min read

Previously we went through launching Android emulator without installing Android studio. In this note we will launch Angular application on that emulator.

First, what we need to do is we have to install build tools by sdkmanager in order to be able to build applications :

sdkmanager "build-tools;29.0.3"

Also we can add %ANDROID_HOME%\emulator and %ANDROID_HOME%\platform-tools as the entries into Path variable to improve the experience. It will allow us to run emulator and adb commands from any directory in command line. Just use Start -> Edit the system environment variables -> Environment variables... -> Path -> New for doing that.

Prepare a NativeScript project for running

If you haven't install nativescript cli yet, you can do it by executing the following command:

npm install -g nativescript

Next, create new project from scratch:

tns create HelloWorld --template tns-template-blank-ng
cd HelloWorld

This is just an example of angular application for running. You can use your own app for this.

Run the emulator

Type the following to see a list of available emulators:

avdmanager list avd

We'll see something like:

Available Android Virtual Devices:
    Name: test_avd_29
    Path: C:\Users\Andrei_Fedotov\.android\avd\test_avd_29.avd
  Target: Google APIs (Google Inc.)
          Based on: Android 10.0 (Q) Tag/ABI: google_apis/x86_64
  Sdcard: 512 MB

Next, let's run the emulator:

emulator -avd test_avd_29

Okay, emulator is working. What we are gonna be doing next is we are just gonna be launching the app on that emulator.

To see a list of available emulators we can use adb:

$ adb devices

Output:

List of devices attached
emulator-5554   device

Or we can use tns :

tns device

Output:Alt Text

By using one of above commands we can know a Device Identifier for launching the app on emulator.

Next, let's use the following command to launch the app:

tns run android --device emulator-5554

After building we'll see the app launched

Alt Text

Troubleshooting

If you're receiving the error Failed to open /qemu.conf, err: 2, try to create this file by executing echo # > c:\qemu.conf and launch cmd as administrator.

Cheers!

Discussion

pic
Editor guide