执行flutter build apk时提示‘flutter’未被识别的问题求助
解决 'flutter' 不是可识别命令的问题
错误信息
flutter: The term 'flutter' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:1
- flutter build apk
+ CategoryInfo : ObjectNotFound: (flutter:String) [], CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException
解决方案
这个问题是因为Flutter的bin目录未添加到系统环境变量中,导致命令行无法定位flutter命令,按以下步骤修复:
- 找到你的Flutter安装路径下的
bin文件夹(从安装位置截图中定位到flutter文件夹内的bin子目录) - 打开系统环境变量配置:右键「此电脑」→「属性」→「高级系统设置」→「环境变量」
- 在「系统变量」区域找到
Path变量,点击「编辑」 - 点击「新建」,将Flutter的bin目录完整路径粘贴进去,依次点击「确定」保存所有设置
- 关闭所有已打开的命令行窗口(PowerShell、CMD等),重新打开一个新窗口
- 输入命令
flutter --version验证配置,若能显示Flutter版本信息,说明配置成功,此时再执行flutter build apk即可正常运行
内容的提问来源于stack exchange,提问作者Drake Nguyen
相关产品推荐
相关产品推荐

