无法在模拟器中启动 AVD。 sh: grep: 找不到命令

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

在 Android Studio 中,启动 AVD 管理器,我选择一个虚拟设备并单击播放按钮启动它。

然后我收到这个错误信息 "Cannot launch AVD in emulator. sh: file: command not found sh: grep: command not found ... "

一直都很好,我想我通过 运行 以下命令弄乱了 PATH 变量。

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

执行这些后,我在终端中也找不到像 ls 这样的简单命令。 然后我通过 运行

修复了它
PATH=/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin

在那之后,lsgrep 等再次正常工作。 我在终端 windows 中检查了它,它之前显示了同样的错误,运行 上面的命令修复了它。

但是,当我尝试启动 AVD 时,它仍然失败并显示上述错误消息。 尝试重新启动,使 cahce 无效,没有任何帮助。

您设置的路径有误。事实上,你只是在更换它。您需要做的是 add 到路径。像这样:

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

一定要在编辑器中查看 ~/.bash_profile 并删除以前的 PATH 条目。

注意添加的 $PATH。这样它会采用以前的路径并附加新路径。

PATH=$PATH:your_path_here