DEV Community

Cover image for Launching Angular app on emulator without Android Studio
Andrei Fedotov
Andrei Fedotov

Posted on • Edited on

4 1

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!

Sentry image

Hands-on debugging session: instrument, monitor, and fix

Join Lazar for a hands-on session where you’ll build it, break it, debug it, and fix it. You’ll set up Sentry, track errors, use Session Replay and Tracing, and leverage some good ol’ AI to find and fix issues fast.

RSVP here →

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay