This post will cover the steps to create an Android Virtual Device (AVD) only using the command line. It is possible to do Android development without an IDE like Android Studio 😀.

🛠 Install Android Commandline Tools

The easiest way to use the standalone Android SDK is by using the android-commandlinetools via Homebrew. Since the sdk depends on Java, that will be needed as well. Im using openjdk@11. Note that android-sdk has been depricated and it is reccomended to use android-commandlinetools.

brew update
brew install openjdk@11
brew cask install android-commandlinetools

Add environment variables for the SDK. Add this to your startup shell script. Most likely ~/.bashrc or ~/.bash_profile.

export ANDROID_SDK_ROOT="/usr/local/share/android-commandlinetools/"

📦 Android SDK Components

  1. build-tools - Component of the Android SDK required for building Android apps.
  2. platform-tools - Tools useful for debugging, such as adb, fastboot, and systrace.
  3. emulator - Launches the AVDs.
  4. system-images - Used for creating an AVD.
  5. platforms - The Android platform to target. This is the version you will build your app against.

We can install all these components together using one command.

sdkmanager "build-tools;30.0.3" "platform-tools" "emulator" "system-images;android-30;google_apis;x86_64" "platforms;android-30"

#verify everything got installed
sdkmanager --list_installed

📱 Create the AVD

Next we’ll use avdmanager to create the android virtual device.

avdmanager create avd -n "Pixel_4A" -d "pixel_4a" -k "system-images;android-30;google_apis;x86_64"

🔥 Start an Emulator with the new AVD

emulator -list-avds
emulator -avd Pixel_4A