无法创建颤振项目:没有为输出目录错误指定选项

Posted

技术标签:

【中文标题】无法创建颤振项目:没有为输出目录错误指定选项【英文标题】:Unable to create a flutter project: No option specified for the output directory error 【发布时间】:2021-08-24 11:13:36 【问题描述】:

我正在尝试创建一个新的 Flutter 项目。我试过了,

1.flutter create

    flutter create --org com.domain.appname

他们都返回了以下内容。

No option specified for the output directory.
Create a new Flutter project.

If run on a project that already exists, this will repair the project,
recreating any files that are missing.

Global options:
-h, --help                  Print this usage information.
-v, --verbose               Noisy logging, including all shell commands
                            executed.
                            If used with "--help", shows hidden options. If used
                            with "flutter doctor", shows additional diagnostic
                            information. (Use "-vv" to force verbose logging in
                            those cases.)
-d, --device-id             Target device id or name (prefixes allowed).
    --version               Reports the version of this tool.
    --suppress-analytics    Suppress analytics reporting when this command runs.

Usage: flutter create <output directory>
-h, --help                   Print this usage information.
    --[no-]pub               Whether to run "flutter pub get" after the project
                             has been created.
                             (defaults to on)
    --[no-]offline           When "flutter pub get" is run by the create
                             command, this indicates whether to run it in
                             offline mode or not. In offline mode, it will need
                             to have all dependencies already available in the
                             pub cache to succeed.
    --[no-]overwrite         When performing operations, overwrite existing
                             files.
    --description            The description to use for your new Flutter
                             project. This string ends up in the pubspec.yaml
                             file.
                             (defaults to "A new Flutter project.")
    --org                    The organization responsible for your new Flutter
                             project, in reverse domain name notation. This
                             string is used in Java package names and as prefix
                             in the ios bundle identifier.
                             (defaults to "com.example")
    --project-name           The project name for this new Flutter project. This
                             must be a valid dart package name.
-i, --ios-language           The language to use for iOS-specific code, either
                             ObjectiveC (legacy) or Swift (recommended).
                             [objc, swift (default)]
-a, --android-language       The language to use for Android-specific code,
                             either Java (legacy) or Kotlin (recommended).
                             [java, kotlin (default)]
    --platforms              The platforms supported by this project. Platform
                             folders (e.g. android/) will be generated in the
                             target project. This argument only works when
                             "--template" is set to app or plugin. When adding
                             platforms to a plugin project, the pubspec.yaml
                             will be updated with the requested platform. Adding
                             desktop platforms requires the corresponding
                             desktop config setting to be enabled.
                             [ios (default), android (default), windows
                             (default), linux (default), macos (default), web
                             (default)]
-t, --template=<type>        Specify the type of project to create.

          [app]              (default) Generate a Flutter application.
          [module]           Generate a project to add a Flutter module to an
                             existing Android or iOS application.
          [package]          Generate a shareable Flutter project containing
                             only Dart code.
          [plugin]           Generate a shareable Flutter project containing an
                             API in Dart code with a platform-specific
                             implementation for Android, for iOS code, or for
                             both.

-s, --sample=<id>            Specifies the Flutter code sample to use as the
                             "main.dart" for an application. Implies
                             "--template=app". The value should be the sample ID
                             of the desired sample from the API documentation
                             website (http://docs.flutter.dev/). An example can
                             be found at:
                             https://api.flutter.dev/flutter/widgets/SingleChild
                             ScrollView-class.html
    --list-samples=<path>    Specifies a JSON output file for a listing of
                             Flutter code samples that can be created with
                             "--sample".

Run "flutter help" to see global options.

下面是我的flutter doctor 输出。

Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 2.2.3, on macOS 11.4 20F71 darwin-arm, locale
    en-LK)
[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
[✓] Xcode - develop for iOS and macOS
[✓] Chrome - develop for the web
[✓] Android Studio (version 4.2)
[✓] VS Code (version 1.59.1)
[✓] Connected device (2 available)

• No issues found!

我正在使用 MacBook Pro M1 芯片笔记本电脑,有帮助吗?

这是怎么回事?

【问题讨论】:

【参考方案1】:

我认为我提出一个简单的问题非常愚蠢,也许我只是长时间工作太累了。无论如何,我犯了一个错误,这是答案。

flutter create --org com.domain appname

注意appnamecom.domain 之间的空格

【讨论】:

【参考方案2】:

您忘记添加输出目录。您需要将其放在 --org 调用之前:

颤振创建 . --org....

.是当前目录,或者指定一个使用

C:/Users/...你的目录路径

【讨论】:

对不起,这也不起作用。它说multiple output directories specified。也许您可以发布完整的命令以确保防错? 另外这个提到的输出目录不是我以前做过的,尽管我已经开发了很多flutter应用程序。 使用 dot . 来指定对我有用的当前目录 flutter create 。 --platforms=windows,macos,linux --org com.packagname 虽然,我只能添加对 macos 的支持;鉴于这是我当前的操作系统

以上是关于无法创建颤振项目:没有为输出目录错误指定选项的主要内容,如果未能解决你的问题,请参考以下文章

长时间打开后无法构建颤振项目

由于错误无法构建角度项目:错误输出为:不推荐使用选项“vendorSourceMap”

无法在 IOS 移动设备上运行我的颤振项目

在你的颤振项目中找不到颤振 sdk 中的飞镖?

颤振错误找不到名为“平台”的选项

命令“颤振:新项目”导致错误(找不到命令“颤振.createProject”),我无法在 VSCODE 上调试颤振项目