How to Install Android Emulator (Android Sdk Manager and AVD manager) without Android studio on MacOS (full terminal).
Here I will show you how to install android sdk without installing android studio using macOS intel. This is very useful if your device is running slow or you don’t like android studio and you want to use some other code editor.
Use a terminal for the tutorial.
Install OpenJDK 8 or latest version.
Download Java at : https://www.oracle.com/id/java/technologies/downloads/
I am using java 19, but if you want to use another version you can visit : https://jdk.java.net/
Setup Folder
I keep everything in one directory. Use the terminal or you can create folders inside the “Home” directory using finder.
cd ~
mkdir .src
cd .src
mkdir Android
cd Android
mkdir sdk
cd sdk
mkdir cmdline-tools
cd cmdline-tools
mkdir tools
cd ../../../
mkdir gradle
Now the complete path looks like this:
For Android sdk :
/Users/<user_name>/.src/Android/sdk/cmdline-tools
For Gradle :
/Users/<user_name>/.src/gradle
Install the Android Command Line Tools.
Download and install the android command line tool :
https://developer.android.com/studio#command-tools (download link is at the bottom).
Open the folder where you downloaded this file and unzip the file
commandlinetools-mac-9477386_latest.zip
Then move the “tools” folder to the “Home/Android/cmdline-tools/” directory.
Now the complete path looks like this :
/Users/<user_name>/.src/Android/sdk/cmdline-tools/tools
Setup Gradle
Because I installed OpenJdk 19, I use gradle version 7.6.1, if you use another version of openjdk you can visit the following url to check the compatibility : https://docs.gradle.org/current/userguide/compatibility.html#java
After that, open the folder where you downloaded the gradle file and unzip the file. Then move the “gradle-7.6.1” folder to the “Home/.src/gradle/” directory.
Now the complete path looks like this :
/Users/<user_name>/.src/gradle/gradle-7.6.1
Setup Environment Variable.
Now go back to the “Home” directory and type nano .zshrc to set up some Environment variables.
cd ~
nano .zshrc
Now write this down in the .zshrc file:
# This Java
export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk-19.0.2.jdk/Contents/Home
# Gradle
export GRADLE_HOME=$PATH:/Users/<user_name>/.src/gradle/gradle-7.6.1
export PATH=$GRADLE_HOME/bin:$PATH
# Android Path
export ANDROID=$PATH:/Users/<user_name>/.src/Android/sdk
export PATH=$ANDROID/cmdline-tools/tools:$PATH
export PATH=$ANDROID/cmdline-tools/tools/bin:$PATH
export PATH=$ANDROID/platform-tools:$PATH
export PATH=$ANDROID/emulator:$PATH
# Android SDK
export ANDROID_SDK_ROOT=$ANDROID
export PATH=$ANDROID_SDK_ROOT:$PATH
Then save the control + x file.
Download Android SDK.
So for android to run, we need to install system-image, platform-tools, build-tools, platform; android.
I am using Android-30, you can use any version compatible with your Android device. If you want to see all available versions for system-image, platform-tools, build-tools, and platforms; android type the following in your terminal :
To see all the lists :
sdkmanager --list
For version 30 type the following command in the terminal :
sdkmanager “system-images;android-30;google_apis_playstore;x86”
sdkmanager "platforms;android-30"
sdkmanager “platform-tools”
sdkmanager "build-tools;30.0.3"
sdkmanager "emulator"
note: if you’re using macOS with silicon use ARM instead of x86.
eg :
sdkmanager "system-images;android-30;google_atd;arm64-v8a"
sdkmanager "platforms;android-30"
sdkmanager "platform-tools"
sdkmanager "build-tools;30.0.3"
sdkmanager "emulator"
Now accept the license :
sdkmanager --licenses
and type “y” for all of its licenses.
After you have received all the licenses, try checking each environment variable that we created by :
where sdkmanager
/Users/<user_name>/.src/Android/sdk/cmdline-tools/tools/bin/sdkmanager
where avdmanager
/Users/<user_name>/.src/Android/sdk/cmdline-tools/tools/bin/avdmanager
where gradle
/Users/<user_name>/.src/gradle/gradle-7.6.1/bin/gradle
If there is no “not found” message, then congratulations Android is successfully setup on your computer.
Now Create an AVD (Android Virtual Device)
to create an avd use this command :
avdmanager create avd --force --name pixel_5_api30 --abi google_apis_playstore/x86_64 --package 'system-images;android-30;google_apis_playstore;x86' --device pixel_5
to run emulator :
emulator -avd pixel_5_api30