I get 'Command Not Found' when I try to run Android Emulator on Mac OS X
Asked Answered
A

7

74

When I use the Mac OS X Terminal to navigate to the folder with my Android Emulator and type emulator, I get:

command not found

Here's what happens:

$ emulator
-bash: emulator: command not found

How do I get it to work?

Adiathermancy answered 22/4, 2012 at 15:32 Comment(2)
Unless you've added the command to your PATH variable you need to specify the path to the binary, i.e. ./emulator from the directory it's in.Cymoid
export PATH=~/Library/Android/sdk/toolsJabber
R
85

The current directory is not normally included in your $PATH on a *nix operating system like OS X; to execute a program in the current directory, precede it with the path to the current directory (.):

$ ./emulator
Reparative answered 22/4, 2012 at 15:35 Comment(6)
OMG this seems to be working! :D So elusive, yet so simple. Thank you!Adiathermancy
which directory am I supposed to be in before I can run ./emulator command?Brood
@blackfyre if you are on mac, try this directory: /Users/<user>/Library/Android/sdk/toolsTolmach
The correct answer would be: edit the /etc/paths file to add your /Users/myusername/Library/Android/sdk/emulator directory to the PATH environment variable. Then the emulator command will work from everywhere, including with build tools, as expected.Shantelleshantha
ln -s ~/Library/Android/sdk/tools/emulator /usr/local/bin/emulatorQueenhood
Tha answer given by Anthony Awuley fixed it for me!Toothache
D
44

solutions

steps

  1. create one symbolic link emulator
# soft link
$ ln -s ~/Library/Android/sdk/tools/emulator /usr/local/bin/emulator

  1. call the command

# check all avd
$ emulator -list-avds

$ emulator @avd_name
# OR
$ emulator -avd avd_name


enter image description here

2. system environment

  1. edit env with vim/vscode
# zsh
$ vim  ~/.zshrc
# OR
$ code  ~/.zshrc


  1. add below lines to the .zshrc file
# export ANDROID_SDK_ROOT=/Users/xgqfrms/Library/Android/sdk

export ANDROID_SDK_ROOT=~/Library/Android/sdk
export ANDROID_HOME=~/Library/Android/sdk
export ANDROID_AVD_HOME=~/.android/avd


  1. update config
# flush update
$ source ~/.zshrc

refs

https://developer.android.com/studio/run/emulator-commandline

Demogorgon answered 27/7, 2021 at 13:44 Comment(2)
Depending on your android studio version, your path could be a little bit different $ ln -s ~/Library/Android/sdk/emulator/emulator /usr/local/bin/emulatorReno
Regarding solution 2 - arent you missing adding those paths to PATH variable?Agminate
R
42

Emulator can be added with Android Studio https://developer.android.com/studio/run/managing-avds.html

To start emulator: ~/Library/Android/sdk/tools/emulator -avd Nexus_5X_API_23

Related question: How do I launch the Android emulator from the command line?

Ranjiv answered 6/6, 2016 at 22:27 Comment(0)
O
20

These 3 command works for me on VS Code Terminal (Mac Book Pro M1)

  1. echo 'export PATH=$PATH:~/Library/Android/sdk/emulator/' >> ~/.bash_profile
  2. source ~/.bash_profile
  3. emulator -list-avds
Orissa answered 15/3, 2022 at 7:37 Comment(2)
As I had Homebrew installed on my Mac M1, so it worked just by one command in terminal: export PATH=$PATH:~/Library/Android/sdk/emulatorHoick
I am on Mac M2, the solution works for me :)Archean
I
5

typcally i use from terminal :

./Library/Android/sdk/emulator/emulator *some action*
Indistinguishable answered 7/6, 2020 at 3:48 Comment(0)
L
4

Open Android Studio. Click on AVD Manager (the icon with the android and phone) [example image: AVD Manager]. See the list of emulators. You should see something like "Install Emulator" if you don't have any.

Once this is successful, you'll get the tools folder downloaded to your ~/Library/Android/sdk

That is the folder you want, because it has the android and emulator command line tools.

Lanie answered 23/12, 2016 at 0:48 Comment(0)
P
0

For those who installed android command line tools using homebrew :

brew install --cask android-commandlinetools

first make sure that everything is properly installed (so you have no incorrect sdk_root install error when you launch the emulator)

# because I installed android-32 and android-34 systems
# —————————————————————————————————————————————————————

sdkmanager "build-tools;32.0.0"
sdkmanager "build-tools;34.0.0"

sdkmanager "platforms;android-32"
sdkmanager "platforms;android-34"

# —————————————————————————————————————————————————————
sdkmanager "platform-tools"

and then following xgqfrms's solution, you can edit your ~/.zshrc :

export ANDROID_SDK_ROOT="/opt/homebrew/share/android-commandlinetools"
# instead of : export ANDROID_SDK_ROOT="/Users/<YOUR_USER_NAME>/Library/Android/sdk"
export ANDROID_HOME="/opt/homebrew/share/android-commandlinetools"
# instead of : export ANDROID_HOME="/Users/<YOUR_USER_NAME>/Library/Android/sdk"
export ANDROID_AVD_HOME="/Users/<YOUR_USER_NAME>/.android/avd"

you can then add the binaries to your path :

ADB_PATH="/opt/homebrew/share/android-commandlinetools/platform-tools/adb"
ANDROID_EMULATOR_PATH="/opt/homebrew/share/android-commandlinetools/emulator/"

export PATH="$ADB_PATH:$PATH"
export PATH="$ANDROID_EMULATOR_PATH:$PATH"

This should solve the problem

Portingale answered 23/6, 2023 at 10:45 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.