378

is there a way to run the emulator without starting the Android Studio first. Perhaps from the command line. I know that this feature was available in older versions and has vanished since then. But perhaps someone found out how to do it anyways?

hippietrail
  • 15,848
  • 18
  • 99
  • 158
HHeckner
  • 4,722
  • 4
  • 23
  • 33
  • 12
    This is my main gripe about android development, the mainstream AOSP support for cli based DIY development with your own text editor is almost non existent... I'm comparing to Vue/React development, which is a world ahead. – Ray Foss Jan 24 '18 at 20:10

36 Answers36

328

The way to run the emulator from the console (I assume that you installed it before, using Android Studio) is:

run

cd ~/Android/Sdk/tools/bin && ./avdmanager list avd

OR

cd ~/Android/Sdk/tools && ./emulator -list-avds

You will get the list od your virtual installed devices. In my case it was:

Available Android Virtual Devices:
  Name: Galaxy_Nexus_API_17
  Device: Galaxy Nexus (Google)
  Path: /home/piotr/.android/avd/Galaxy_Nexus_API_17.avd
  Target: Google APIs (Google Inc.)
  Based on: Android 4.2 (Jelly Bean) Tag/ABI: google_apis/x86
  Skin: galaxy_nexus
  Sdcard: /home/piotr/.android/avd/Galaxy_Nexus_API_17.avd/sdcard.img

Copy name of the device you want to run and then

cd ~/Android/Sdk/tools && ./emulator -avd NAME_OF_YOUR_DEVICE

in my case:

cd ~/Android/Sdk/tools && ./emulator -avd Nexus_5X_API_23

Rohit Nishad
  • 2,570
  • 2
  • 22
  • 32
Piotr Galas
  • 4,518
  • 2
  • 21
  • 30
  • 60
    Just a heads-up: For me the sdk was located in `/Users//Library/Android/sdk` – flaky May 05 '17 at 06:51
  • 6
    The last command gives me an error `bash: ./emulator: No such file or directory`. Any ideas how to solve this ? – Dhyey Jul 23 '17 at 07:37
  • I think i was mistake using '|', you need to use '&&' instead. I'm not bash ninja. I edited answer – Piotr Galas Jul 23 '17 at 17:45
  • 4
    Depending on how installation of the SDK occurred, you _may_ have the environment variable `$ANDROID_HOME` set to the SDK location. `cd $ANDROID_HOME/tools/bin && ./avdmanager list avd` and `cd $ANDROID_HOME/tools && ./emulator -avd ` – Joshua King Sep 22 '17 at 14:58
  • @Dhyey got into the same issue. verify the path mentioned and try again. worked for me. – Nabeel K Oct 24 '17 at 07:16
  • 2
    @PiotrGalas thank you so much. Finally after a long research your answer was very much helpful – Pitchiah Natarajan Feb 27 '18 at 08:57
  • 3
    Slightly Shorter command: `~/Library/Android/Sdk/tools/emulator -avd Nexus_5` ... (no need for `cd` and `&& ./`) this way your current directory won't change – Sodj Aug 30 '18 at 12:28
  • 2
    WINDOWS: // see list of emulator devices cd %ANDROID_HOME%\tools\bin && avdmanager.bat list avd // run emulator cd %ANDROID_HOME%\tools\ && emulator.exe -avd Pixel_2_API_23 – AntonIva Oct 29 '18 at 16:36
  • 2
    Updating because the avdmanager is not necessary anymore. On Windows 10, you can run Android\Sdk\tools\emulator.exe -list-avds to get the list. – Matt Kenefick Dec 20 '18 at 16:42
  • emulator has been moved to the emulator folder in Android\Sdk. Executing it from there works. – Akhoy Feb 03 '19 at 09:08
  • Thanks your answer works, however it requires the cmd to be open for as long as I want the avd to stay open.. Is there a way to open the avd in a different process, so I could close down the cmd as soon as the avd launches? – Daniel B. Jun 05 '19 at 06:37
  • @DanielB. I do not know :/ – Piotr Galas Jun 05 '19 at 07:11
  • you can also get the avds directly from the emulator now: `./emulator -list-avds` – phrogg Jan 10 '20 at 16:37
  • I had to use `-list-avds` – j4hangir May 24 '20 at 13:23
  • 1
    you can also use `cd ~/.android/avd/ && ls` to get your emulators, for each emulator, there is a .ini file and a .avd file, and the name before the .ini/.avd is the name of the emulator – Cyao Aug 14 '22 at 18:32
  • [Windows] if you're getting `PANIC: Missing emulator engine program for 'x86' CPU`, change path from `...Sdk/tools` to `...Sdk/emulator` – 101is5 Dec 26 '22 at 13:57
164

On MacOS

First list down the installed emulators

~/Library/Android/sdk/tools/emulator -list-avds

then run an emulator

~/Library/Android/sdk/tools/emulator -avd Nexus_5X_API_27
zeeawan
  • 6,667
  • 2
  • 50
  • 56
99

You can make a batch file, that will open your emulator directly without opening Android Studio. If you are using Windows:

  • Open Notepad

  • New file

  • Copy the next lines into your file:

     cd /d C:\Users\%username%\AppData\Local\Android\sdk\tools
     emulator @[YOUR_EMULATOR_DEVICE_NAME]
    

    Notes:

  • Replace [YOUR_EMULATOR_DEVICE_NAME] with the device name you created in emulator

  • To get the device name go to: C:\Users\%username%\AppData\Local\Android\sdk\tools

  • Run cmd and type: emulator -list-avds

  • Copy the device name and paste it in the batch file

  • Save the file as emulator.bat and close

  • Now double click on emulator.bat and you got the emulator running!

PoolloverNathan
  • 148
  • 2
  • 11
mottaz hejaze
  • 1,140
  • 8
  • 6
  • 9
    Windows also has %LOCALAPPDATA% as a variable, you could shorten that to: `%LOCALAPPDATA%\Android\sdk\emulator\emulator @Pixel_2_API_27` (part after the @ is a device name, obtained from the mentioned `-list-avds` – amenthes Apr 09 '18 at 19:01
  • Just typing `C:` is enough to change the drive. When I include the forward slash, ie `C:/`, I get an error in both Powershell and Command Prompt. – Rokit May 19 '18 at 20:37
  • nice work. but if i close the command line, emulator too closes. can fix it or not? – Dyno Cris May 07 '20 at 19:55
  • 1
    It's not working for me the terminal opens and closes after double clicking – Zeeshan Ahmad Khalil Mar 28 '21 at 17:01
  • 3
    @ZeeshanAhmadKhalil Newer versions of Android SDK have the following emulator path: `C:\Users\%username%\AppData\Local\Android\sdk\emulator`. So just replace the first line with `cd /d C:\Users\%username%\AppData\Local\Android\sdk\emulator`. – Rubek Joshi Jul 04 '21 at 13:13
44

Try this

1. Complete Video tutorials (For all windows versions)

OR

2. Text tutorials

  • Open the command prompt and change the directory where your sdk is placed D:\Softwares\Android\sdk\tools\bin>

  • now add your avdmanager in this,now your full code is D:\Softwares\Android\sdk\tools\bin>avdmanager list avd

  • it will show you a list of emulator device that you have already created after few seconds

  • now typecd..

  • and run your emulator with this cmd, Here my emulator name is Tablet_API_25 so I have typed this name after the -avd.

    D:\Softwares\Android\sdk\tools>emulator -avd Tablet_API_25

EDIT : For Android Studio 3.2 or later, the path changes to D:\Softwares\Android\sdk\emulator\emulator -avd Tablet_API_25

i.e. %ANDROID_HOME%\tools\emulator -avd [AVD NAME]

enter image description here

Community
  • 1
  • 1
Sunil
  • 3,785
  • 1
  • 32
  • 43
  • 13
    on my Windows 10 machine, "avdmanager list avd" command did not work; i used "emulator -list-avds" in the tools/ directory. In case this helps someone else :) – dean.huczok Oct 04 '17 at 23:42
  • 4
    why i received error, [1020]:ERROR:android/android-emu/android/qt/qt_setup.cpp:28:Qt library not found at ..\emulator\lib64\qt\lib Could not launch 'C:\Users\afaid\.android\avd\..\emulator\qemu\windows-x86_64\qemu-system-x86_64.exe': No such file or directory – Han Whiteking Nov 16 '17 at 01:22
  • @HanWhiteking Have you tried to check the path you are specifying is correct or not ? – Sunil Nov 16 '17 at 04:34
  • 8
    Emulators in recent versions have been moved out of the `tools` folder and are located in the `emulator` folder. For reference: `C:\Users\USER_NAME\AppData\Local\Android\Sdk\emulator` – j3ff Nov 22 '18 at 14:26
  • Thanks this worked with slight changes. For me the android sdk was in C:/Users//AppData/Local/Android/sdk/. Just go to C:/Users//AppData/Local/Android/sdk/emulator and run `emulator.exe -list-avds` to get device name. Then run `emulator.exe -avd ` – sweetpoision Jun 03 '21 at 13:47
40

Open your terminal and

cd path_to/Android/Sdk/emulator

And run the following to get the emulator name that you created before using android studio

./emulator -list-avds

Replace $emulator_name with the one you want to launch and run

./emulator -avd $emulator_name
Daniel Raouf
  • 2,307
  • 1
  • 22
  • 28
35

If you are starting emulator for Flutter applications, then you can run below command -

> flutter emulators --launch [Emulator ID]

In my case, emulator id is Pixel_2_API_29 as i created it with AVD manager in Android studio. so the command in my case is below -

> flutter emulators --launch Pixel_2_API_29

Thanks

Rahul
  • 1,063
  • 2
  • 11
  • 22
29

In the ANDROID_HOME folder you will have tools folder

In Mac/Linux emulator -avd <avdName> In Windows emulator.exe -avd <avdName>

If you are using API 24 You can get the names of the emulator from the list android list avds If you are using API 25 then you will get it with avdmanager in tools\bin avdmanager list avds

Soumya Swaroop
  • 351
  • 2
  • 3
21

to list the emulators you have

~/Library/Android/sdk/tools/emulator -list-avds

for example, I have this Nexus_5X_API_24

so the command to run that emulator is

cd ~/Library/Android/Sdk/tools && ./emulator -avd Nexus_5X_API_24
DeyaEldeen
  • 10,847
  • 10
  • 42
  • 75
19

In Ubuntu 20.04, I found following solution

First You need to export Android path variables. For that :

export ANDROID_SDK=~/Android/Sdk
export PATH=$ANDROID_SDK/emulator:$ANDROID_SDK/tools:$PATH

The paths may change according to your installation path. If Android Studio is installed using Ubuntu Software then path will be same as stated above.

If the export worked correctly, then following command should list your AVD names.

emulator -list-avds

In my case, I got the result

Nexus_5_API_30

Which is the name of my AVD.

If the above command have listed your AVD name, then you could run your AVD by :

emulator @YOUR_AVD_NAME

In my case

emulator @Nexus_5_API_30

You could add the export commands to .bashrc file to avoid typing export command every time you needed to run your AVD .

anoopknr
  • 3,177
  • 2
  • 23
  • 33
18

A Picture worth thousand words :)

How to Start AVD from MAC terminal

AVD from MAC Terminal

Faisal Naseer
  • 4,110
  • 1
  • 37
  • 55
15
cd C:\Users\{computer_user_name}\AppData\Local\Android\Sdk\emulator

then run:

./emulator -list-avds
or
emulator -list-avds

output:

PIXEL_2_API_29
PIXEL_2_XL_API_29

then run:

./emulator -avd PIXEL_2_XL_API_29
or
emulator -avd PIXEL_2_XL_API_29

That's it

Harat
  • 1,340
  • 1
  • 17
  • 20
  • 1
    `C:\users\%username%\AppData\Local\Android\Sdk\emulator\emulator -list-avds` output: `Pixel_3a_API_30` then: `C:\users\%username%\AppData\Local\Android\Sdk\emulator\emulator -avd PIXEL_3a_API_30` – nyz Oct 04 '20 at 04:07
14

Mac-specific solution (applescript)

The applescript below will show a simple GUI which allows you to pick the android image you want to launch.

Android emulator launcher GUI

The script can be run from the terminal or from the ootb script Editor.app window > Run ▶.

You can convert the script to a standalone Mac app by selecting from script editor.app File > Export... > File Format: Application > Save to /Applications folder.

### TODO! Set the correct path to your `emulator` command
set avds to paragraphs of (do shell script "~/Library/Android/sdk/emulator/emulator -list-avds")
set avd to (choose from list avds with prompt "Please select an AVD to start" default items "None" OK button name {"Start"} cancel button name {"Cancel"})
do shell script "~/Library/Android/sdk/emulator/emulator -avd " & avd & " -no-boot-anim > /dev/null 2>&1 &"

Note: To look up the correct path to the emulator run which -a emulator in a terminal.

In order to run the script from the terminal make it executable (e.g. chmod +x android_launcher.sh), and add the following shebang line at the top:

#!/usr/bin/osascript
ccpizza
  • 28,968
  • 18
  • 162
  • 169
12

Here’s what you need to do:

1.Download and extract the SDK.
2.Open a terminal and navigate to the “tools” directory.
3.Launch the “android” tool (./android if you are currently in the tools directory).
4.Tick off the “SDK Platform” for each version of Android that you’d like to use in your emulator.
5.Click the “Install N Packages” button.
6.Click each package and tick off “Accept License” (legally, I’m probably required to tell you that this step may take several hours as you read each license ;).
7.Done with those licenses? Great. Click “Install”. Wait for the SDK manager to finish installing your packages, then you can close it.
8.Back in your terminal, still in the tools directory, enter ./android avd which will launch the Android Virtual Device Manager.
9.Click “New” and fill out the form to build the device you’d like to emulate. In the “Target” dropdown, you’ll see the SDK Platforms that you installed earlier. If the version you need is missing, you need to go back and install it. Click OK when you’re done.
10.Click on the device that you just created and click the “Start” button, tweak any options that you need on the Launch Options window, and click “Launch”.

Check this question's answer also.

Community
  • 1
  • 1
Farmer
  • 4,093
  • 3
  • 23
  • 47
10

Firstly change the directory where your avd devices are listed; for me it is here:

cd ~/Android/Sdk/tools

Then run the emulator by following command:

./emulator -avd Your_avd_device_name

For me it is:

./emulator -avd Nexus_5X_API_27

That's all.

Vicrobot
  • 3,795
  • 1
  • 17
  • 31
9

Assuming you have installed Android studio properly,Open a command prompt and type emulator -list-avds which will display all the devices and then type emulator @avd_name where avd_name is the the name of your emulator installed.

TRomesh
  • 4,323
  • 8
  • 44
  • 74
9

If you are on windows, what about a shortcut ? It is very easy to place whatever you want ant the icon is descriptive and nice.

  • First, navigate to your android sdk, probably at C:\Users\YOURUSERNAME\AppData\Local\Android\Sdk\tools\
  • Then right click on emulator.exe and then click create shortcut.
  • Your new and shiny shortcut gets created, probably with a predefined name.
  • Right click on the shortcut, and on the target field (my computer is on spanish) add an extra parameter with the name of your device with an @ in front (take a look at the picture below )

shortcut params

now you can do whatever yhou want with that shortcut, put on the desktop, bind it to the start-menu or whatever

Community
  • 1
  • 1
Danielo515
  • 5,996
  • 4
  • 32
  • 66
  • Consider replacing the "@" with "-avd ". For some reason, when using the "@", after closing the properties window and opening it again will not show the "@" although it still works. when using the "-avd " all the command stays there even if you close and reopen the properties window. – Jorge Galvão Feb 13 '20 at 21:58
  • Well, I didn't used a windows laptop in a year, but if you provide me a newer screenshot I will update it. It will have to wait otherwise. – Danielo515 Feb 14 '20 at 13:41
7

Assuming you've got Android Studio installed, and SDK in your PATH, it's:

emulator -avd avd_name

To get a list of AVD names, run:

emulator -list-avds

Source: https://developer.android.com/studio/run/emulator-commandline.html

designorant
  • 2,344
  • 14
  • 25
7
 Update 2020/05:
 Windows 10

first get a list of emulators, open cmd and run :

cd %homepath%\AppData\Local\Android\Sdk\emulator

then

emulator -list-avds

next create a shortcut of emulator.exe found in the directory above, then change the properties in it by editing the Target: text box like this

emulator.exe @YourDevice

enter image description here

DarkPh03n1X
  • 600
  • 1
  • 7
  • 17
5

I already have the Studio installed. But without starting (not installing) the Android Studio you can directly start the emulator with

C:\Users\YOURUSERNAME\AppData\Local\Android\Sdk\tools\emulator.exe -netdelay none -netspeed full -avd YOUR_AVD_NAME

HHeckner
  • 4,722
  • 4
  • 23
  • 33
5

The path for emulator is

/Users/<Username>/AppData/Local/Android/sdk/tools
Pang
  • 9,564
  • 146
  • 81
  • 122
Steve Blanco
  • 51
  • 1
  • 1
5

For Linux/Ubuntu

Create a new File from Terminal as

gedit emulator.sh (Use any Name for file here i have used "emulator")

now write following lines in this file

cd /home/userName/Android/Sdk/tools/

./emulator @your created Android device Name

(here after @ write the name of your AVD e.g

./emulator @Nexus_5X_API_27 )

Now save the file and run your emulator using following commands

./emulator.sh

In case of Permission denied use following command before above command

chmod +x emulator.sh

All set Go..

5

I am working with a React Native project and I also faced this problem

I solved it by making a .bat file in my desktop that I can open fast

The content of the .bat is

C:\Users\haria\AppData\Local\Android\sdk\emulator\emulator -avd Pixel_2_XL_API_27

Where haria is my Windows username and Pixel_2_XL_API_27 is my emulator name


If you want to see your emulator name, open CMD (or PowerShell) and type (In Windows)

cd C:\Users\haria\AppData\Local\Android\sdk\emulator

Then to see the emulator(s) name

./emulator -list-avds

Hari Anugrah
  • 484
  • 1
  • 7
  • 12
4

Got it working for Windows 10:

C:\Users\UserName\AppData\Local\Android\Sdk\tools>emulator -list-avds
Nexus_5X_API_28
C:\Users\UserName\AppData\Local\Android\Sdk\emulator>emulator -avd Nexus_5X_API_28
Rukala
  • 245
  • 3
  • 10
4

This is the commands on Mac

cd ~/Library/Android/Sdk/tools/bin && ./avdmanager list avd

then

cd ~/Library/Android/Sdk/tools && ./emulator -avd NAME_OF_YOUR_DEVICE
Andy Wilson
  • 121
  • 8
4

For Windows users:

  • Copy your Emulator name.
  • Go to this directory: C:\Users\[yourusername]\AppData\Local\Android\Sdk\emulator
  • Right click on emulator.exe and send as a shortcut to where you want.
  • Right click on shortcut .exe file and add your Emulator name just copied to end of target textbox with @ symbol.
  • Double click your shortcut and done!

C:\Users\[yourusername]\AppData\Local\Android\Sdk\emulator\emulator.exe @EmulatorName

Badiparmagi
  • 1,285
  • 1
  • 14
  • 24
4

in 2019 , there might have some changes due to android studio update.

  1. open command prompt [ cmd ]
  2. change directory to sdk > tools

    cd C:\Users\Intel\AppData\Local\Android\sdk\tools

if that address is not working 2.a open android studio 2.b open Gradle Scripts directory ( if you have a open project inside android studio, you can easily find in left side of the screen. ) 2.c double click on local properties ( at the very bottom ) 2.d you should see the address right away, ( sdk dir ) 2.e change your directory to that address in command prompt ( like cd AppData ) 2.f change directory again to tools ( cd tools )

  1. check the list of emulators that you all ready created by

    emulator -list-avds

  2. copy your preferred emulator name.

  3. choose and run your emulator by

    emulator -avd < your preferred emulator name >

  4. done.

Muhammed Shamil
  • 161
  • 2
  • 4
  • 3
    Just wanna point out that you can also create a desktop shortcut easily after that. Right click on desktop > new > shortcut and then paste in something like "C:\Users\User\AppData\Local\Android\Sdk\tools\emulator.exe -avd Nexus_6P_API_23" – BlackSoil Sep 08 '19 at 03:09
  • 4
    Perfect solution! The best way to use the emulator in my opinion. In my case, there is an error **(PANIC: Missing emulator engine program for 'x86' CPU.)** occurring when I run `emulator -avd ...`, then, I managed to fix it by navigating to `...\Android\Sdk\emulator` instead of `\tools` – Frederiko Ribeiro Dec 24 '19 at 17:41
3
  1. Just create a .bat file. Call it smth like "run pixel 2.bat"
  2. Open it with editor like Notepad++
  3. Write 2 lines of code
cd C:\Users\mxsof\AppData\Local\Android\Sdk\emulator 
emulator -avd pixel_2_api_29
  1. Launch it.

That's all. Happy coding!

Dyno Cris
  • 1,823
  • 1
  • 11
  • 20
2

(Only for Windows) Why to torture yourself? Make a Simple BAT file ! :

  1. Open Notepad
  2. Create the command as shown below
  3. Save as *.bat
  4. (Optional) Create a shortcut to that *.bat, rename shortcut and change icon

Here is the command:

cd /d yourSdkPath\emulator && emulator -avd yourAVDName

Example:

cd /d D:\Android_SDK\emulator && emulator -avd Nexus_5_API_28

Zakir Shikhli
  • 397
  • 4
  • 14
2

this is how I've added a 'Start Pixel Emulator' to my start menu, and launched emulator in the same way as Android studio did:

enter image description here

this method can used to re-create any process launched by other process. let's start:

first I launched the emulator in the traditional way(from android studio)

enter image description here

and then I opened procmanager (from sysinternals) and used 'Find windows process (drag over window)' tool, and selected the emulator

enter image description here

this action brings up the specific process that is responsible for this windows window.

then I inspected the command that android studio used to open the emulator.

enter image description here

enter image description here

enter image description here

Android studio use this command to start the emulator:

C:\Software\Android\Sdk\emulator\emulator.exe -netdelay none -netspeed full -avd Pixel_6_API_33

let's create a new bat file with the exact same command

enter image description here

Then I used this guide to turn this script into a shortcut that can be attached to start menu.

for Dessert I wanted to also change the icon, so i used the icon of the emulator.exe file

enter image description here

enter image description here

now im starting the emulator in the same way android studio do it, but via a shortcut and without opening android studio.

Eliav Louski
  • 3,593
  • 2
  • 28
  • 52
1

if you installed Git on your system. then you can run .sh bash code. I create the bash code for search from your created ADV Devices and list them. then you can select the number of adv device for run emulator without running Android studio.

link: adv-emulator.sh

note [windows os]: please first add %appdata%\..\Local\Android\Sdk\emulator to your system Environment path, otherwise the bash-code not work.

Hamed Taheri
  • 164
  • 2
  • 11
1

On windows

......\Android\sdk\tools\bin\avdmanager list avds

......\Android\sdk\tools\emulator.exe -avd Nexus_5X_API_27
Sumit Garai
  • 1,205
  • 8
  • 6
  • 8
    Brings up PANIC: Missing emulator engine program for 'x86' CPU. Although I can start it in Android Studio? – HHeckner Jul 11 '18 at 17:42
  • You can go to $ANDROID_HOME/emulator -avd DEVICE_NAME https://stackoverflow.com/questions/26483370/android-emulator-error-message-panic-missing-emulator-engine-program-for-x86 – brownmagik352 Sep 08 '18 at 00:51
  • @user668338 You should use `emulater.exe` found in `$ANDROID_HOME\emulator` folder, rather than the one found in `$ANDROID_HOME\tools`. – Paul Siersma Sep 12 '19 at 12:21
1

Here is what I've done to run the emulator quickly in windows : I've created a windows batch file like this :

start C:\Users\{Username}\AppData\Local\Android\Sdk\emulator\emulator.exe -avd {Emulator_Name}

and just run the batch file every time I need the emulator.

Mehran Rasa
  • 99
  • 1
  • 5
  • 2
    the emulator has moved to the emulator directory, use C:\Users\{Username}\AppData\Local\Android\Sdk\emulator\emulator.exe instead – Jacolack Jan 19 '19 at 22:53
1

If you are on windows then create a .bat file and just double click that .bat file which will save you some time every day. Here is my code to launch android Emulator with use of batch file:

@echo off
title Android Emulator
color 1b
echo #################################

echo Please make sure that your android path is correct for the script
echo Change this path "C:\Users\YOUR_USER_NAME\AppData\Local\Android\Sdk\emulator" to use your curret path and save it as a .bat file on your system to launch android emulator
echo #################################
c:
cd C:\Users\YOUR_USER_NAME\AppData\Local\Android\Sdk\emulator
emulator -avd Nexus_5X_API_28

pause
connect2Coder
  • 1,122
  • 1
  • 13
  • 25
1

For Windows Users

  1. create and open a bat file(.bat is the extension of file)
  2. Put the following code inside the file

    cd /d Path of SDK folder \emulator && emulator -avd Name of Emulator

Here is the example

cd /d E:\Run\Android_Installation_Final\Sdk\emulator && emulator -avd Pixel_API_28
  1. Save it.
  2. Run it from any cmd(command prompt shell)

you can see my post to auto start emulator when windows start

Irshad Babar
  • 1,311
  • 19
  • 26
1

You may create a shell script and put it in your desktop:

Dim WinScriptHost
Set WinScriptHost = CreateObject("WScript.Shell")
WinScriptHost.Run "C:\Users\<user>\AppData\Local\Android\Sdk\emulator\emulator -avd <AVD_NAME>", 0
Set WinScriptHost = Nothing

Replace <user> with your user id, and <AVD_NAME> with the name of your avd file, e.g. pixel_2_api_28.

James MA
  • 323
  • 5
  • 14
0

For Windows

In case anyone looking for shortcut / batch script - Gist - Download batch file.

@echo off
IF [%1]==[] (GOTO ExitWithPrompt)
set i=1
FOR /F "delims=" %%i IN ('emulator -list-avds') DO (
    set /A i=i+1
    set em=%%i
    if %i% == %1 (
        echo Starting %em%
        emulator -avd %em%
        EXIT /B 0
    )
)
GOTO :Exit
:ExitWithPrompt
emulator -list-avds
echo Please enter the emulator number to start

:Exit
EXIT /B 0

Usage

D:\>start-emulator
Nexus_5_API_26
Please enter the emulator number to start

D:\>start-emulator 1
Starting Nexus_5_API_26
HAX is working and emulator runs in fast virt mode.