'Flutter Could not find a command named "-" and Exception: Gradle task assemble Debug failed with exit code 64

Could not find a command named "-".

Usage: dart [] <command|dart-file> []

Global options:

-h, --help                 Print this usage information.
-v, --verbose              Show additional command output.
    --version              Print the Dart SDK version.
    --enable-analytics     Enable anonymous analytics.
    --disable-analytics    Disable anonymous analytics.

Available commands:

  analyze   Analyze the project's Dart code.
  compile   Compile Dart to various formats.
  create    Create a new project.
  format    Idiomatically format Dart source code.
  pub       Work with packages.
  run       Run a Dart program.
  test      Run tests in this package.

Run "dart help " for more information about a command. See https://dart.dev/tools/dart-tool for detailed documentation. Exception: Gradle task assembleDebug failed with exit code 64 Exited (sigterm)



Solution 1:[1]

Okay so I had a similar issue to this, and here is what I found out.

So first things first, running "flutter doctor" gave me green lights across the board so I know that's not an issue.

I have my flutter SDK installed under my D drive (D:/flutter/bin)

Originally I tried to create a basic hello world project with this file structure: D:\Development\Flutter\Flutter & Dart - The Complete Guide\hello_world

So then when I ran the "flutter run" command I would be greeted with an error like this:

Using hardware rendering with device sdk gphone x86. If you notice graphics artifacts, consider enabling software rendering with "--enable-software-rendering". Launching lib\main.dart on sdk gphone x86 in debug mode... Could not find a command named "-".

Usage: dart <command|dart-file> [arguments]

Global options: -h, --help Print this usage information. -v, --verbose Show additional command output. --version Print the Dart SDK version. --enable-analytics Enable analytics. --disable-analytics Disable analytics.

Available commands: analyze Analyze Dart code in a directory.
compile Compile Dart to various formats. create Create a new Dart project. devtools Open DevTools (optionally connecting to an existing application). doc Generate HTML API documentation from Dart documentation comments. fix Apply automated fixes to Dart source code. format Idiomatically format Dart source code. migrate Perform null safety migration on a project. pub
Work with packages. run Run a Dart program. test Run tests for a project.

Run "dart help " for more information about a command. See https://dart.dev/tools/dart-tool for detailed documentation. Running Gradle task 'assembleDebug'... 822ms Exception: Gradle task assembleDebug failed with exit code 64

So then I went a few directories back and created another hello_world project with the file path of: D:\Development\Flutter\hello_world

But this time when I ran the same "flutter run" command it actually worked.

My guess would be that there is some kind of issue with either the name of the folder used or how deeply nested the folders were.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Alchemist