Install Android Emulator without Studio IDE

November 9, 2024370 words2 mins read

Android Emulator

Sometimes you want to install the Android emulator on Windows (the steps can be reproduced on all platforms, but for the scope of this document we’re talking about Windows), but without installing the whole Android Studio, maybe you’re using or testing Android apps and you don’t want to go through the hassle of installing the whole IDE.

Start by installing the Java SDK if you don’t have it already installed.

Go to the Android Studio download page and download the Command line tools only package for Windows. Extract it somewhere and rename the cmdline-tools directory to latest. Make an android directory somewhere and a cmdline-tools directory inside and put the latest directory with all the files inside the cmdline-tools dir.

If you created the android directory in the root of the C drive, the structure should be similar to this (the C:\android\ part can be anything you want, the rest of the path must be cmdline-tools\latest:

C:\android\cmdline-tools\latest

Create an environment variable named ANDROID_SDK_ROOT and make sure its value is the path to the cmdline-tools directory, excluding that. If you installed everything as above, the value should be C:\android.

Open a PowerShell instance, change directory to the C:\android\cmdline-tools\latest\bin and run sdkmanager.bat:

PS C:\android\cmdline-tools\latest\bin> .\sdkmanager.bat --list

Next, install the platform-tools and emulator packages (type y when you’re asked to accept the license):

PS C:\android\cmdline-tools\latest\bin> .\sdkmanager.bat platform-tools emulator

Next, install the platform-specific packages, in this case platforms, build-tools and system images:

PS C:\android\cmdline-tools\latest\bin> .\sdkmanager.bat "platforms;android-34"
PS C:\android\cmdline-tools\latest\bin> .\sdkmanager.bat "build-tools;34.0.0"
PS C:\android\cmdline-tools\latest\bin> .\sdkmanager.bat "system-images;android-34;google_apis;x86_64"

You should append to system path variable the path to emulator, platform-tools and cmdline-tools\latest\bin directories, so the binary files inside them will be accessible from everywhere.

After everything is installed we can create the AVD (Android Virtual Device), you will be asked if you want to change the default configuration, just press ENTER key:

avdmanager create avd --name Android34 --package "system-images;android-34;google_apis;x86_64"

And launch the Android emulator with the AVD we just created:

emulator -avd Android34

Configuration for the AVD can be found inside the config.ini file that’s inside .android\avd\Android34.avd\ in your home directory. If you want to install an Android system image that’s based on a different Android version, like 32, adjust all the PowerShell commands (replace 34 with 32).