Update Your Path For The New Android Emulator Location
Since March 2017 (v25.3.0), the Android Emulator has been released separately from the rest of the Android SDK tools. As part of implementing this change, the emulator
binary was ‘promoted’ from ${ANDROID_SDK_ROOT}/tools/
1 to its own top-level directory, ${ANDROID_SDK_ROOT}/emulator/
. This relocation can cause some issues. I’ll show you how to avoid them.
At the time of the change, it was indicated that old versions of Android Studio should be unaffected. However, I recently needed to launch the emulator from the command line to test customized Android system images, and in doing so discovered some rough edges:
$ ${ANDROID_SDK_ROOT}/tools/emulator -avd my-custom-avd
PANIC: Missing emulator engine program for 'x86' CPU.
If I run this same command using the relocated emulator
, the AVD launches successfully:
$ ${ANDROID_SDK_ROOT}/emulator/emulator -avd my-custom-avd
HAXM is working and emulator runs in fast virt mode
This is despite the fact that
$ ${ANDROID_SDK_ROOT}/tools/emulator -version
and
$ ${ANDROID_SDK_ROOT}/emulator/emulator -version
both report the same version information:
Android emulator version 26.1.2.0 (build_id 4077558) (CL:500db745bd44dbc6000413b5e8969d83216ff7cd)
I’m guessing the error is due to a discrepency in the emulator-related files found in each location:
$ ls ${ANDROID_SDK_ROOT}/tools/ | grep "emulator"
emulator
emulator-check
$ ls ${ANDROID_SDK_ROOT}/emulator/ | grep "emulator"
emulator
emulator-check
emulator64-arm
emulator64-crash-service
emulator64-mips
emulator64-x86
I’m not sure why this discrepancy exists.
If, like me, all you care about is having easy command-line access to the newest emulator
binary, I recommend updating your $PATH
to include
${ANDROID_SDK_ROOT}/emulator
Make sure this appears before2 any existing reference to
${ANDROID_SDK_ROOT}/tools
in your $PATH
so that the correct emulator
binary is prioritized:
$ which emulator
/Users/stkent/Library/Android/sdk/emulator/emulator
Happy emulating!
-
In writing this post I also discovered for the first time that
${ANDROID_HOME}
has been deprecated in favor of${ANDROID_SDK_ROOT}
. Read more in the Android Studio User Guide section on Environment Variables. ↩ -
Run
echo $PATH
to check the full contents of your$PATH
variable. Searched paths are separated by a colon and searched first-to-last. ↩