'flutter' command is not working in Root Directory of Project. [Windows]

12,304

Solution 1

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.

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.

Solution 2

First you need to be sure that all the environmental variables are valid/correct, you may need to restart terminal (cmd or your PC) for the changes to take effect.

If that doesn't work you can try setting PATH in cmd/terminal. This usually resets the PATH in cmd (not the Environmental Variables) to the new variable specified, to avoid this use:

set path=%PATH%;C:\Program Files\Git\bin;C:\...

The above command appends the specified path to the already existing PATH rather than overwriting it.

Hope this helps

Share:
12,304

Related videos on Youtube

Manish
Author by

Manish

Updated on September 16, 2022

Comments

  • Manish
    Manish over 1 year

    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

    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'.

    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' is not recognized as an internal or external command, operable program or batch file.

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

    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.