Cannot launch AVD in emulator. sh: grep: command not found

核能气质少年 提交于 2019-12-11 08:34:15

问题


In Android Studio, launch AVD Manager, I choose one of my virtual device and click Play button to start it.

Then I get this error message "Cannot launch AVD in emulator. sh: file: command not found sh: grep: command not found ... "

It's fine all the while and I think I mess up with the PATH variable by running the following command.

echo 'export PATH=/Users/xxx/Library/Android/sdk/tools' >> ~/.bash_profile
echo 'export PATH=/Users/xxx/Library/Android/sdk/platform-tools' >> ~/.bash_profile

After executing these, I couldn't find simple command like ls in Terminal too. Then I fixed it by running

PATH=/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin

After that, ls, grep etc are working fine again. I check it in the Terminal windows, it is showing the same error before, running the above command fixed it.

However, when I try to launch AVD, it still failed with the error message above. Try to restart, invalidate cahce, nothing help.


回答1:


You are setting your path wrong. In fact you are just replacing it. What you need to do is to add to path. Like this:

echo 'export PATH=$PATH:/Users/xxx/Library/Android/sdk/platform-tools' >> ~/.bash_profile

Be sure to view ~/.bash_profile in editor and remove previous PATH entries.

Note the added $PATH. This way it takes the previous path and appends the new one.

PATH=$PATH:your_path_here


来源:https://stackoverflow.com/questions/32723435/cannot-launch-avd-in-emulator-sh-grep-command-not-found

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!