Flutter - 找不到名为“-”的命令

时间:2021-02-17 13:34:22

标签: flutter dart gradle

我是flutter的新手,当我创建一个新的flutter项目并运行它时,会出现:

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

Usage: dart [<vm-flags>] <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 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.
  fix       Apply automated fixes to Dart source code.
  format    Idiomatically format Dart source code.
  migrate   Perform a null safety migration on a project or package.
  pub       Work with packages.
  run       Run a Dart program.
  test      Run tests in this package.

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

我被这个问题困住了,如何解决这个问题?

2 个答案:

答案 0 :(得分:0)

我已经解决了这个问题。我在我的 D: 目录中运行这个项目,而我的 flutter 和 android SDK 安装在 C: 目录中。因此,当我尝试在 C: 中创建 flutter 项目时,它奏效了。但是,我仍然无法配置为什么会出现此问题。

答案 1 :(得分:0)

@Papskipaapp 请问,如果在 D: 上运行您的项目还包括一些包含“-”(破折号)的路径名?根据经验:保持路径名简单,即没有空格或除“_”(下划线)以外的特殊字符,许多工具无法处理这些......