How to quickly start your Android Emulator

Android Apr 27, 2023

Tired of opening Android Studio every time to just start your emulator? So was I, with that in mind I created a simple script that will start my emulator in a matter of seconds. This script is written for Windows machines, but I am sure that other operating systems have similar approaches.

1. Find the Id of the emulator you want to start.

First of all, let us get the Id of the emulator we want to start. There are 2 ways to do this.

1.1 Android Studio

The first way is to open the Virtual Device Manager in Android Studio.

  1. Open Android Studio;
  2. Click the More Actions button;
  3. Click Virtual Device Manager.
android_studio_opening_virtual_device_manager

After these actions, you will see a list of your available Android Emulators. Unless you do not have any emulators then you can create one by clicking the CREATE DEVICE button on the top left of the screen.

android_studio_showing_available_emulators

Now we can get the id of the emulator with the following steps.

  1. Click the More Actions button of the emulator you want;
  2. Click View Details.

Now on the bottom of the screen, you will see the AvdId, which in my case is Pixel_5_API_33.

android_studio_showing_avdid

1.2 Command Prompt

The second way is to use the Command Prompt.

Open the Command Prompt, by pressing the Windows button and typing cmd and pressing Enter. If for some reason you cannot find it, type command prompt instead.

In the Command Prompt you want to navigate to the following path: AppData\Local\Android\Sdk\emulator by executing cd AppData\Local\Android\Sdk\emulator.

This path should be the same for you if you installed Android Studio using the default setup.

terminal_navigating_to_our_emulator

Now we can execute the following command to get our available emulator id's: emulator -list-avds.

terminal_listing_our_available_avds

Every line is one emulator id.

2. Creating the script

Now that we have the id of the emulator, let us make sure that we can run our emulator from the Command Prompt. We can do this by executing the following command: emulator -writable-system -avd $your_avd_id in the same path as we navigated to in chapter 1.2 where $your_avd_id is the id of the emulator we searched before.

If you did not follow this step then make sure you navigate to the following path using the Command Prompt: cd \AppData\Local\Android\Sdk\emulator. If you need more instructions please refer back to chapter 1.2.
terminal_starting_our_emulator_and_showing_the_emulator

As you can see the emulator got started.

Emulator.bat

To create the script create a .bat file, you can do this from your Desktop.

  1. Right mouse click on the Desktop;
  2. Click New;
  3. Click Text Document.
windows_create_new_text_document

Give the file a name of your choice but make sure to suffix it with .bat. I will name my file emulator.bat of course, you can also use the emulator id in the name of the file if you want to have multiple scripts to run different emulators.

If you have written the file name, you can press Enter and click Yes on the warning message.

windows_changing_the_name_of_our_text_document

Now we need to write our commands, and open Notepad by right-clicking the script and clicking Edit.

windows_opening_the_editor_of_our_text_document

In the script we want to write the following commands:

Make sure to replace:

  • tijnv with your user;
  • Pixel_5_API_33 with your emulator id.
@echo off
pushd C:\Users\tijnv\AppData\Local\Android\Sdk\emulator
emulator -writable-system -avd Pixel_5_API_33

The commands will do the following:

  1. Make sure that the commands we execute are not printed;
  2. Navigate to the right path;
  3. Open our emulator.

After you have changed the commands, you can click save and run the script.

terminal_running_our_script_and_showing_the_emulator

There we go, we have started our emulator with 1 click!

Now every time you want to start developing you simply have to click your .bat file and your emulator will start. For quick access I pinned my emulator to the Start Menu, so I only have to press the Windows button, to access it.

3. Conclusion

Running this script can save you some time and makes the start of your day a little easier. I hope you learned something from it and I hope you enjoy using the script. For me, it is very fast and makes sure that I do not have to start Android Studio anymore because I am programming in Intellij myself.

Tags