Search code examples
androidandroid-studioandroid-emulatorandroid-sdk-tools

How to start Android emulator via the command line on a Mac with Apple Silicon?


Problem

I get the following error when trying to start the Android emulator via the command line:

Could not launch '~/Library/Android/sdk/emulator/qemu/darwin-x86_64/qemu-system-aarch64': No such file or directory

Reproduction steps

  1. Use a Mac with Apple Silicon.
  2. Have an emulator already set up, for example Pixel 8 on Android 14 (API level 34).
  3. Run command to start emulator with the emulator name, for example: ~/Library/Android/sdk/tools/emulator @Pixel_8_API_34.

Starting the emulator via the virtual device manager GUI has no problems.

Investigation so far

Possible cause

The error looks to be occurring because the correct location of the emulator binary is:

~/Library/Android/sdk/emulator/qemu/darwin-aarch64/qemu-system-aarch64

Compare with the incorrect location:

~/Library/Android/sdk/emulator/qemu/darwin-x86_64/qemu-system-aarch64

Information from -verbose

Running with -verbose gives the following information:

emulator:Android emulator version 26.0.3.0 (build_id 3965150)
emulator:Found AVD name 'Pixel_8_API_34'
emulator:Found AVD target architecture: arm64
emulator:argv[0]: '~/Library/Android/sdk/tools/emulator'; program directory: '~/Library/Android/sdk/tools'
emulator:Auto-config: -engine qemu2 (arm64 default)
emulator:  Found directory: ~/Library/Android/sdk/system-images/android-34/google_apis_playstore/arm64-v8a/

emulator:try dir ~/Library/Android/sdk/tools
emulator:try dir ~/Library/Android/sdk/tools/
emulator:try dir ~/Library/Android/sdk/emulator
emulator:Found target-specific 64-bit emulator binary: ~/Library/Android/sdk/emulator/qemu/darwin-x86_64/qemu-system-aarch64
emulator:Adding library search path: '~/Library/Android/sdk/emulator/lib64'
emulator:Adding library search path: '~/Library/Android/sdk/emulator/lib64/gles_swiftshader'
emulator:Adding library search path: '~/Library/Android/sdk/emulator/lib64/gles_angle'
emulator:Adding library search path: '~/Library/Android/sdk/emulator/lib64/gles_angle9'
emulator:Adding library search path: '~/Library/Android/sdk/emulator/lib64/gles_angle11'
emulator: Adding library search path for Qt: '~/Library/Android/sdk/emulator/lib64/qt/lib'
emulator: Setting Qt plugin search path: QT_QPA_PLATFORM_PLUGIN_PATH=~/Library/Android/sdk/emulator/lib64/qt/plugins
emulator: Running :~/Library/Android/sdk/emulator/qemu/darwin-x86_64/qemu-system-aarch64
emulator: qemu backend: argv[00] = "~/Library/Android/sdk/emulator/qemu/darwin-x86_64/qemu-system-aarch64"
emulator: qemu backend: argv[01] = "@Pixel_8_API_34"
emulator: qemu backend: argv[02] = "-verbose"
emulator: Concatenated backend parameters:
 ~/Library/Android/sdk/emulator/qemu/darwin-x86_64/qemu-system-aarch64 @Pixel_8_API_34 -verbose
Could not launch '~/Library/Android/sdk/emulator/qemu/darwin-x86_64/qemu-system-aarch64': No such file or directory

System information

Android Studio:

  • Version: Android Studio Iguana | 2023.2.1
  • Runtime version: 17.0.9+0-17.0.9b1087.7-11185874 aarch64
  • VM: OpenJDK 64-Bit Server VM

Virtual device:

  • avd.ini.displayname: Pixel 8 API 34
  • AvdId: Pixel_8_API_34
  • image.androidVersion.api: 34
  • image.sysdir.1: system-images/android-34/google_apis_playstore/arm64-v8a/

Information from documentation

I've looked at the documentation for starting the Android emulator on the command line but am not certain if there's an option.


Solution

  • The issue lies in the fact that you're using

    ~/Library/Android/sdk/tools/emulator
    

    which contains an outdated version of the emulator that no longer receives updates, ever since Google updated the Android SDK structure, and decided to put the emulator in a separate location from other tools.

    You should be using this instead:

    ~/Library/Android/sdk/emulator/emulator