Launching Angular app on emulator without Android Studio

andreisfedotov

Andrei Fedotov

Posted on June 29, 2020

Launching Angular app on emulator without Android Studio

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"
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode

Next, create new project from scratch:

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

Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode

Next, let's run the emulator:

emulator -avd test_avd_29
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode

Output:

List of devices attached
emulator-5554   device
Enter fullscreen mode Exit fullscreen mode

Or we can use tns :

tns device
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode

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!

💖 💪 🙅 🚩
andreisfedotov
Andrei Fedotov

Posted on June 29, 2020

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related