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.
- Open Android Studio;
- Click the More Actions button;
- Click 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.
Now we can get the id of the emulator with the following steps.
- Click the More Actions button of the emulator you want;
- Click View Details.
Now on the bottom of the screen, you will see the AvdId, which in my case is
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
This path should be the same for you if you installed Android Studio using the default setup.
Now we can execute the following command to get our available emulator id's:
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.
As you can see the emulator got started.
To create the script create a
.bat file, you can do this from your Desktop.
- Right mouse click on the Desktop;
- Click New;
- Click 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.
Now we need to write our commands, and open Notepad by right-clicking the script and clicking Edit.
In the script we want to write the following commands:
Make sure to replace:
tijnvwith your user;
Pixel_5_API_33with 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:
- Make sure that the commands we execute are not printed;
- Navigate to the right path;
- Open our emulator.
After you have changed the commands, you can click save and run the script.
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.
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.