'flutter'命令在项目的根目录中不起作用.[视窗] [英] 'flutter' command is not working in Root Directory of Project. [Windows]

查看:127
本文介绍了'flutter'命令在项目的根目录中不起作用.[视窗]的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我能够在"C:\ Users \ pc \ AppData \ Local \ Android \ flutter \ bin"路径下运行"flutter"命令.但是在尝试生成APK时,如果我将路径更改为Project Root Directory,则"flutter"命令不起作用.

I am able to run 'flutter' commands at "C:\Users\pc\AppData\Local\Android\flutter\bin" path. But while trying to generate APK, if i change the path to Project Root Directory, 'flutter' command doesn't work.

我已经添加了环境变量的所有路径,如其他各种问题所述,包括:

I have added all the paths to Environment Variable as mentioned in various other asked questions, including:

C:\ Users \ pc \ AppData \ Local \ Android \ flutter \ bin
C:\ Program Files \ Android \ Android Studio \ jre \ bin \ java
C:\ Program Files \ Git \ bin

C:\Users\pc\AppData\Local\Android\flutter\bin
C:\Program Files\Android\Android Studio\jre\bin\java
C:\Program Files\Git\bin

如果我将Android Studio中的终端路径更改为"C:\ Users \ pc \ AppData \ Local \ Android \ flutter \ bin",则"flutter"命令运行正常.我能够运行"flutter -doctor"之类的命令.

The 'flutter' command is working fine if i change the path of terminal in Android Studio to "C:\Users\pc\AppData\Local\Android\flutter\bin". I am able to run commands like 'flutter -doctor'.

但是当我试图使用'flutter build apk'生成要发布的apk时,我正在使用终端中设置的默认路径,即项目的根目录.它说:

But while i'm trying to generate apk for release using 'flutter build apk', i'm using the default path set in the terminal i.e. the root directory of the project. It says:

'flutter'不被识别为内部或外部命令,可操作的程序或批处理文件.

'flutter' is not recognized as an internal or external command, operable program or batch file.

如果我尝试在"C:\ Users \ pc \ AppData \ Local \ Android \ flutter \ bin"中运行相同的命令,则输出为:

If i try to run the same command in "C:\Users\pc\AppData\Local\Android\flutter\bin", the output is:

错误:找不到pubspec.yaml文件.此命令应从Flutter项目的根目录运行.不要从Flutter的git克隆的根目录运行此命令.

Error: No pubspec.yaml file found. This command should be run from the root of your Flutter project. Do not run this command from the root of your git clone of Flutter.

如果有人可以向我提出建议以使其正常工作,那将真的很有帮助.

It'd be really helpful, if anyone can suggest me something to make it work.

推荐答案

我仍然无法通过Project Root目录中Android Studio内部的终端运行"flutter run"或"flutter build apk"之类的命令.

I'm still unable to run commands like 'flutter run' or 'flutter build apk' through the terminal inside Android Studio at my Project Root Directory.

但是,当在flutter sdk文件夹中的flutter_console.bat中运行时,这些相同的命令可以很好地运行.因此,使用flutter_console.bat,我只是更改了项目根目录的路径,并使用"flutter build apk --release"命令生成了apk.

However, these same commands run perfectly well while running in the flutter_console.bat located in the flutter sdk folder. So using the flutter_console.bat , i just change the path to Project Root Directory and generate the apk using 'flutter build apk --release' command.

这篇关于'flutter'命令在项目的根目录中不起作用.[视窗]的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆