未找到颤振命令
显然,没有任何 Flutter 命令在 Android Studio 的终端中运行,我相信我正在尝试在我的项目的根目录中运行它.
Apparently, none of the Flutter commands are working in the terminal of Android Studio which I believe I am trying to run it at the root of my project.
输出:
bash: flutter: command not found
您需要正确设置 Flutter 路径.
You need to correctly set up your Flutter path.
确定放置 Flutter SDK 的目录.您将在第 3 步中用到它.
Determine the directory where you placed the Flutter SDK. You will need this in Step 3.
打开(或创建)$HOME/.bash_profile
.您可以使用终端文本编辑器进入终端并输入 nano ~/.bash_profile
Open (or create) $HOME/.bash_profile
. You can do that by using terminal text editor by going in terminal and typing nano ~/.bash_profile
macOS v10.15 (Catalina) 默认使用 Z shell,所以编辑 $fileHOME/.zshrc.
macOS v10.15 (Catalina) uses the Z shell by default, so edit $file HOME/.zshrc.
如果您使用不同的 shell,文件路径和文件名在您的机器上会有所不同.
If you are using a different shell, the file path and filename will be different on your machine.
添加以下行并将[PATH_TO_FLUTTER_GIT_DIRECTORY]
更改为您克隆Flutter的Git存储库的路径:
Add the following line and change [PATH_TO_FLUTTER_GIT_DIRECTORY]
to be the path where you cloned Flutter’s Git repository is:
export PATH=[PATH_TO_FLUTTER_GIT_DIRECTORY]/flutter/bin:$PATH
例如:
export PATH=~/Documents/flutter/bin:$PATH
按Ctrl + X,当它要求你保存文件时,选择是
Press Ctrl + X and when it asks you to save the file, choose Yes
运行 source $HOME/.bash_profile
刷新当前窗口或重启终端
Run source $HOME/.bash_profile
to refresh the current window or restart the terminal
通过运行以下命令验证 flutter/bin
目录现在是否在您的 PATH 中:
Verify that the flutter/bin
directory is now in your PATH by running:
echo $PATH
请注意,[PATH_TO_FLUTTER_GIT_DIRECTORY]
是您安装 Flutter SDK 的位置,而不是您应用的位置
Notice that [PATH_TO_FLUTTER_GIT_DIRECTORY]
is where you installed Flutter SDK, not the location of your app
代替nano,您可以使用任何文本编辑器来编辑文件~/.bash_profile
.
Instead of nano, you can use any text editor to edit file ~/.bash_profile
.
对于 zsh:
- 打开终端
- 运行:
nano ~/.zshrc
- 添加:
export PATH=[PATH_TO_FLUTTER_GIT_DIRECTORY]/flutter/bin:$PATH
- 运行:
source ~/.zshrc
- 重启终端
- 运行:
flutter doctor -v
例如:如果你机器上的flutter已经安装在[your_username]/Developer/flutter下
For example : if flutter in your machine has been installed under [your_username]/Developer/flutter
export PATH=Developer/flutter/bin:$PATH