Usually, we install Android Studio to run our code in its Android Emulator. This emulator is usually called AVD (Android Virtual Device) Emulator, which is a very handy tool especially if you don't want to setup your personal device for the testing usecase. But, sometimes you don’t need Android Studio but still need the AVD Emulator, so it's just overkill to install heavy Android Studio to just run Android Emulator.
So we'll see how we can install and run AVD Emulator without installing Android Studio. Here’s the step to step guide to install AVD Emulator to your Mac without installing Android Studio. Same can be followed for linux based devices.
Install Java (If already not)
Java is used to build and run the emulator and related tools. Java must be installed in your system. You can download Java by following below steps:
- Download appropriate Java package or installer from Official Oracle website
- If you use the installer(recommended), that will set appropriate paths as well.
Get Tools package
tools
package is part of Android SDK, a group of packages that are needed for Android development. tools
package is used for managing other packages to create AVD's. Here's the step for getting the tools package:
- Go to Official Android Studio download page.
- Scroll down to "Command line tools only" section.
- Download the package according to your OS by clicking on it.
- Extract the package to the folder you want. I use below for my Macbook:
- Single User:
/Users/shivamsharma/Library/Android/sdk
- Globally:
/Library/Android/sdk
- Single User:
- Move content of
cmdline-tools
to a folder namedlatest
insidecmdline-tools
. e.g. Final path for bin becomes:/Users/shivamsharma/Library/Android/sdk/cmdline-tools/latest/bin
Add Environment variables
We need to add environment variable to our bash/zsh profile for Android and Java Executables. By doing this we'll be able to run the command line tools or binary files from evrywhere in the machine.
To do the same
- Add below content in your bash file e.g.
~/.zshrc
:
######## Android #########
export ANDROID_SDK_ROOT="/Users/shivamsharma/Library/Android/sdk"
export ANDROID_HOME="/Users/shivamsharma/Library/Android/sdk" #(Deprecated, but some programs still using it to locate SDK)
export PATH="$ANDROID_HOME/cmdline-tools/latest/bin/:$PATH"
export PATH="$ANDROID_HOME/emulator/:$PATH"
export PATH="$ANDROID_HOME/platform-tools/:$PATH"
- Source the bash file by running
source ~/.zshrc
. As we have added path ofcmdline-tools/latest/bin/
inPATH
so we can call CLI commands available in that folder from anywhere.
Download essential packages
Now, we will download platform-tools
and emulator
packages.
platform-tools
has some tools to communicate with Android devices when you plug them into your computer. emulator
is the Android emulator.
We will use sdkmanager
or sdkmanager.bat
which are placed at cmdline-tools/bin
to install them.
You can check if sdkmanager
is working by running sdkmanager --list
. This will give the list of packages available to install with sdkmanager
.
- Run
sdkmanager platform-tools emulator
to install platform-tools and emulator. Read and accept licences. - Install android image you are interested e.g. I am using
android-34
here which is SDK for Android 14 by runningsdkmanager "system-images;android-34;google_apis_playstore;arm64-v8a" "platforms;android-34"
. Read and accept licences by typingy
.
Create AVD device
We will use the avdmanager
command to create an AVD device. This command is usually placed in cmdline-tools/latest/bin
directory, so if you've already config the environment variable correctly, you can just call the command from everywhere.
Here’s an example of a command about how to create an AVD device:
avdmanager create avd --name '${DeviceName}' --package "system-images;android-34;google_apis_playstore;arm64-v8a" -d pixel
Replace ${DeviceName}
with the device name you want.
You will be asked if you want to change some default configurations. You can change it later in config.ini
the file that is located in the AVD directory, so for now we will just continue the installation.
You can create any number of emulator by changing the device name in the above command
To create emulator with different Android version you can download the respective System image using command mentioned in previous step and use the system image name downloaded to create new emulator with with that android version
Run the emulator
Run the emulator using below command:
emulator -avd ${DeviceName} -no-snapshot-load
Use control + c
in the terminal to close the emulator. Or switch off the device emulator using android controls.
Steps Summary
- Install Java: https://www.oracle.com/java/technologies/downloads/#jdk23-mac
- Download and Unzip Android Cmd tools to a new folder https://developer.android.com/studio#command-line-tools-only
- e.g.
/Users/shivamsharma/Library/Android/sdk
for single user, for global user at/Library/Android/sdk
- e.g.
- Move content of
cmdline-tools
to a folder namedlatest
insidecmdline-tools
. e.g. Final path becomes:/Users/shivamsharma/Library/Android/sdk/cmdline-tools/latest/bin
- Add below content in
~/.zshrc
######## Android #########
export ANDROID_SDK_ROOT="/Users/shivamsharma/Library/Android/sdk"
export ANDROID_HOME="/Users/shivamsharma/Library/Android/sdk"
export PATH="$ANDROID_HOME/cmdline-tools/latest/bin/:$PATH"
export PATH="$ANDROID_HOME/emulator/:$PATH"
export PATH="$ANDROID_HOME/platform-tools/:$PATH"
- Reload source file:
source ~/.zshrc
. As we have added path ofcmdline-tools/latest/bin/
inPATH
so we can call CLI commands available in that folder from anywhere. - Check if you can run
sdkmanager --list
- Run
sdkmanager platform-tools emulator
to install platform-tools and emulator. Read and accept licences. - Run
sdkmanager "system-images;android-34;google_apis_playstore;arm64-v8a" "platforms;android-34"
to install android image you are interested in e.g. usingandroid-34
here which is SDK for Android 14. Read and accept licences. - Create device with command
avdmanager create avd --name '${DeviceName}' --package "system-images;android-34;google_apis_playstore;arm64-v8a" -d pixel
- Run emulator by
emulator -avd ${DeviceName} -no-snapshot-load
.-no-snapshot-load
is there to load the device from fresh instead of from a snapshot.
Top comments (1)
The guide on running the Android Emulator without installing Android Studio provides a streamlined approach for developers looking to test applications without the overhead of a full IDE. This method is particularly useful for those who want to focus on app development efficiently. For users interested in enhancing their music experience, exploring options like Deezer Premium APK can offer additional features and benefits. For more details, check out deezer premium apk.