When you develop apps or games for Android you probably want to run it on a simulator during development. In this short post I will show you how to start such a simulator both from the UI as well as from the terminal.

How to run an Android simulator on a Macbook

Don’t laugh when I tell you that the first time I was trying to launch an Android simulator, I couldn’t find it! Actually, most posts I stumbled upon only described to start the AVD manager from Android Studio. But still I couldn’t find it. The thing is: you will need to create an Android project first and let it build completely. After the build completes you will find the AVD manager from the tools menu. So this is how it goes in detail:

Install Android Studio

Let’s begin by downloading Android Studio if you didn’t do so already! This is the download link

Create a new AVD (emulator)

There are basically two options:
1a. Launch Android Studio and in the first dialog click the little Gear icon and select AVD manager
1b. Select the option to Start a new Android Studio Project and select the Empty activity template. Accept the defaults and click Finish.

After your project was loaded select the Tools option from the menu bar and select AVD manager. The following screen will appear:

2. Click the Create Virtual Device button and select one from the list. Now keep in mind that if you want to test for instance Google Play Game services, make sure you select one with the Play Store icon next to it. In the screenshot above you can see that I have create two AVD for two different devices.

Also make sure you choose a simple name. My first image is called playerb and my second image playera instead of the usual device name. This is easier when you try to start devices through the terminal.

After the AVD’s have been created you can start them by clicking on the Play icon from the UI. That’s it!

Start simulator from terminal

First, let us list all of the simulators we have. Start a terminal session by hitting Command+Space and type Terminal or by whatever shortcut you prefer. Then type:

Emulator -list-avds

It will show you a list of all the AVDs you have created with the AVD Manager.

To launch one of those, in my case with the name playera, type:

Emulator -avd playera

And there you go!

Bonus: deploy your Unity game to a simulator (AVD)

Now that your simulator is up and running you probably want to push you application or Unity game to it. This, you can do by script / terminal as well!

Below you will find a script which will deploy an .apk file to all running instances and ALSO connected (through USB) devices. This is very useful as it will save you a lot of time. Some tools will do that for you automatically, but the script below might come in handy when you want to do it yourself or as part of an automated build solution.

Replace the name of the APK in the script below. Secondly, you need to specify the bundle ID. Third, you have to specify the main activity. For unity games it is something like com.unity3d.player… but if you are using Prime31 third party plugins, the main activity is wrapped and you should use the one which I commented out and looks like com.prime31.Unityplayer…

Save the script below to the location where your APK resides and call it deploy.sh. Next, launch a terminal session, browse to the script location and run the script by typing: sh deploy.sh.

Have fun!



install_to_device() {
  local prettyName=$(adb -s $1 shell getprop ro.product.model)
  echo "
  Installing to $prettyName"
  adb -s $1 install -r "${APK_PATH}"
  adb -s $1 shell am start -n "${BUNDLE_ID}/${MAIN_ACTIVITY}"
  adb -s $1 shell input keyevent KEYCODE_WAKEUP
adb devices -l
for SERIAL in $(adb devices | tail -n +2 | cut -sf 1);
  install_to_device $SERIAL&