68

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?

tripleee
  • 175,061
  • 34
  • 275
  • 318
Kebman
  • 1,901
  • 1
  • 20
  • 32

7 Answers7

84

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
Community
  • 1
  • 1
eggyal
  • 122,705
  • 18
  • 212
  • 237
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?

Community
  • 1
  • 1
Vlad Vinnikov
  • 1,457
  • 3
  • 22
  • 33
36

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

xgqfrms
  • 10,077
  • 1
  • 69
  • 68
  • Depending on your android studio version, your path could be a little bit different `$ ln -s ~/Library/Android/sdk/emulator/emulator /usr/local/bin/emulator` – William S. Takayama Feb 17 '23 at 15:05
12

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
Ryan M
  • 18,333
  • 31
  • 67
  • 74
Wasit Shafi
  • 854
  • 1
  • 9
  • 15
  • As I had Homebrew installed on my Mac M1, so it worked just by one command in terminal: `export PATH=$PATH:~/Library/Android/sdk/emulator` – Harshal Jun 28 '22 at 03:18
5

typcally i use from terminal :

./Library/Android/sdk/emulator/emulator *some action*
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.

Anney
  • 99
  • 1
  • 9
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