If you're a macOS user looking to run Android emulators, especially those with Google Play Store support, this comprehensive guide will walk you through the entire process. Using Homebrew simplifies the installation and management of the necessary tools, ensuring compatibility with Apple Silicon (M1/M2) chips.
Step 1: Install Homebrew
First, ensure Homebrew is installed on your macOS. Homebrew is a package manager for macOS that simplifies the installation of software. If Homebrew is not already installed, open Terminal and run:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
Step 2: Install Android Command Line Tools
Next, use Homebrew to install the Android Command Line Tools. This set of tools allows you to create and manage Android Virtual Devices (AVDs) from the command line.
brew install --cask android-commandlinetools
Step 3: Set Up Environment Variables
Configure your environment variables to include the Android SDK paths. This ensures that the command line tools can locate the necessary files. Add the following lines to your ~/.zshrc
(or ~/.bash_profile
if you use bash):
export ANDROID_HOME=$HOME/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
Apply the changes to your shell configuration:
source ~/.zshrc
# or
source ~/.bash_profile
Step 4: Download Required System Images
Use the sdkmanager
to download the necessary system images. Since Apple Silicon uses the ARM architecture, ensure you download ARM images instead of x86 images. This example downloads the Android 34 system images with Google Play Store support for ARM.
sdkmanager "platform-tools" "emulator" "platforms;android-34" "system-images;android-34;google_apis_playstore;arm64-v8a"
Step 5: Create an AVD
Create a new Android Virtual Device (AVD) using a device definition and the downloaded system image. This example creates an AVD for the Pixel 6 Pro device with Google Play Store support.
avdmanager create avd -n Pixel_6_Pro_API_34_PlayStore_ARM -k "system-images;android-34;google_apis_playstore;arm64-v8a" --device "pixel_6_pro"
Step 6: List Available AVDs
Verify that your AVD has been created successfully by listing all available AVDs:
avdmanager list avd
You should see an entry similar to:
Available Android Virtual Devices:
Name: Pixel_6_Pro_API_34_PlayStore_ARM
Device: pixel_6_pro (Google)
Path: /Users/yourusername/.android/avd/Pixel_6_Pro_API_34_PlayStore_ARM.avd
Target: Google Play (Google Inc.)
Based on: Android API 34 Tag/ABI: google_apis_playstore/arm64-v8a
Sdcard: 512 MB
Step 7: Run the Emulator
Start the emulator using the created AVD. This command launches the emulator with GPU acceleration and a specific screen resolution:
emulator -avd Pixel_6_Pro_API_34_PlayStore_ARM -gpu on -skin 1440x3120
Step 8: Remove Unused AVDs
If you have AVDs that are no longer needed or are incompatible, you can delete them to free up space and reduce clutter. List all AVDs to identify which ones you want to remove:
avdmanager list avd
Delete unwanted AVDs using their names:
avdmanager delete avd -n Pixel_6_Pro_API_34
avdmanager delete avd -n Pixel_6_Pro_API_34_PlayStore
Conclusion
By following these steps, you can set up an Android emulator on macOS that is compatible with the latest devices and OS versions, and includes Google Play Store support. This setup allows you to test and run Android applications smoothly, leveraging the full capabilities of Apple Silicon if applicable. Using Homebrew simplifies the management of the necessary tools, making the process straightforward and efficient.
If you encounter any issues or need further customization, the Android developer documentation and community forums are excellent resources for additional help. Happy developing!
Top comments (1)
I tried to install on a MacBook Pro 16" M1 MAX. Here is theterminal response for the commandlinetools and temurin install:
I found no .zshrc file in my home directory, so I created one with your export commands. The other steps apparently were completed successfully. But when tryyng to start the emulator I get the following:
How can I fix this? Your help is deeply appreciated, thank you in advance
Mario Pittteri email pitteri@tiscali.it