How to run Android Emulator without Android Studio?

secabit
3 min readNov 4, 2020

The article was created to show how to install emulator and tools without Android Stuio. If you are a tester, you don’t need to download the entire Android environment. This way you will save time and gigabytes on hard drive. In this tutorial, I have presented the necessary steps for Windows and Mac Os.

1. Install android-sdk.

In order to install the necessary packages you need Android SDK which contains the basic tools and allows you to install more packages.

Windows

The easiest way is to install Android SDK on Windows is with the help of the Choco package manager. If you don’t have Choco, here you will find instructions how to install it. https://chocolatey.org/install

  • Open PowerShell with administrator rights and run the following command: choco install android-sdk -y

This command will also automatically install Java JDK 1.8.

Mac Os

In the case of Mac Os, there are a few more steps. The easiest way is to install android-SDK on Mac Os is with the help of the Brew package manager. If you don’t have Brew, here you will find instructions how to install it. https://brew.sh/

Open terminal and run the following commands:

  • Install android-sdk brew install android-sdk
  • Install Java brew cask install homebrew/cask-versions/adoptopenjdk8

After these steps, you should be able to run sdkmanager --help in your terminal.

You can also download android-sdk from the Android Studio website, but you will have to manually configure all environment variables additionally. In case of an update you will have to copy it manually again, so I recommend using package managers.

2. Install required packages with sdkmanager.

In this step, we will install packages needed to run an emulator. SDKManager is basically the same tool as in Android Studio, but here in the command-line interface.

Windows:

  • Open terminal and run the command:
sdkmanager "system-images;android-28;default;x86" "platforms;android-28" "platforms;android-28" "extras;intel;Hardware_Accelerated_Execution_Manager"
  • Go to directory C:\Android\android-sdk\extras\intel\Hardware_Accelerated_Execution_Manager and install HAXM by running intelhaxm-android.exe
  • Add C:\Android\android-sdk\emulator to system PATH environment variable, it should be placed before other android-sdk variables. It will allow to run emulator in terminal regardless current directory.
PATH environment variable

Mac Os

  • Open terminal and run the command:
sdkmanager "emulator" "platform-tools" "platforms;android-30" "system-images;android-28;default;x86" "tools"
  • Edit the file ~/.zshrc (for ex. with nano) and insert the below lines. Similarly to Windows the emulator in the PATH variable will allow you to run it anywhere.
# Android-sdk
export ANDROID_HOME=/usr/local/share/android-sdk
export ANDROID_SDK_ROOT=$ANDROID_HOME
export ANDROID_SDK_HOME=$ANDROID_HOME
export PATH=$ANDROID_HOME/emulator:$PATH
# Java
export JAVA_HOME="/Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk/Contents/Home"

I chose the package versions above, but you can change them. Remember that the above packages are necessary to run the emulator.

You can also install other packages depending on what you need. Check the list with the command sdkmanager --list and then install in the same way as above, remember about the double quotes.

If you need build tools on Mac you can also install it with sdkmanager "build-tools;30.0.2", but after you have to add environment variable manually with specific version, for ex. export PATH=$ANDROID_HOME/build-tools/30.0.2:$PATH.

3. Create virtual device with avdmanager.

Here commands are the same on Windows and Mac Os.

To create virtual device use the command:

avdmanager create avd -n VirtualDeviceName -k "system-images;android-28;default;x86" -d "7in WSVGA (Tablet)"

Where:

  • -n is the device name, you can set whatever you want
  • -k is system package installed with sdkmanager
  • -d is target device, you can list available devices with avdmanager list devices

4. Run the device with the emulator program.

It’s time to start the created machine by running command:

emulator -avd VirtualDeviceName

or

emulator @VirtualDeviceName

Where VirtualDeviceName, is the name of created machine in step 3.

If the emulator doesn’t run on Mac Os, you need to provide access into System Preferences — Security & Privacy

Summary

I hope that it will be easier for you to setup your AndroidSDK with this tutorial and you will get the basics about required things. In many cases, the use of command line is better because of the ease of automation and speed of operations.

--

--

secabit

Hacker and an engineer interested in networks, electronics, programming, and many others.