【问题标题】:Stuck on step 2b in the Flutter Native Plugin guide停留在 Flutter Native Plugin 指南中的第 2b 步
【发布时间】:2020-06-22 12:20:27
【问题描述】:

所以我正在尝试开始 Flutter 插件开发,但我被困在步骤 2b HERE

Android Studio 只是显示错误:

Cannot Import Project
The project file specified already exists.

我很确定我已按照说明进行操作:

  1. flutter create --org com.example --template=plugin hello
  2. cd hello/example; flutter build apk

这些步骤一切正常,示例应用程序似乎已构建,然后我进入步骤 2b,Android Studio 显示上述错误。

扑扑医生:

[✓] Flutter (Channel dev, 1.20.0-1.0.pre, on Mac OS X 10.13.6 17G13035, locale en-DK)
[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
[!] Xcode - develop for iOS and macOS
    ✗ Xcode installation is incomplete; a full installation is necessary for iOS development.
      Download at: https://developer.apple.com/xcode/download/
      Or install Xcode via the App Store.
      Once installed, run:
        sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer
        sudo xcodebuild -runFirstLaunch
[✓] Android Studio (version 4.0)
[✓] VS Code (version 1.46.1)
[✓] Connected device (1 available)

【问题讨论】:

    标签: flutter flutter-plugin


    【解决方案1】:

    直接打开项目比较容易,但要注意使用哪个文件夹。

    在 Android Studio 中,在 File>Open 中导航到 hello/example/android。这将打开示例应用程序。 gradle 完成同步后,您应该会在左侧面板中看到示例应用程序(您不会更改)和插件代码(您会更改)。

    当您安装了 VS Code 后,请考虑使用它来编辑 Dart 代码。 (在开发插件时,尝试将 Android Studio 用于 Dart 代码以及 Java/Kotlin 代码时,我会感到困惑。)在这种情况下,打开顶级文件夹 (hello)。您需要对 hello/lib/hello.dart(插件 API)和 hello/example/lib/main.dart(使用 API 的 Flutter 应用示例)进行更改。

    【讨论】:

    • 谢谢!他们确实需要更新他们的文档以反映这一点。
    猜你喜欢
    • 2016-10-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-02-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多