flutter - 停留在 Flutter Native Plugin 指南中的第 2b 步
问题描述
所以我正在尝试开始 Flutter Plugin 开发,但我被困在步骤 2b HERE上。
Android Studio 只是显示错误:
Cannot Import Project
The project file specified already exists.
我很确定我已按照说明进行操作:
flutter create --org com.example --template=plugin hello
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)
解决方案
简单地打开项目更容易,但要小心使用哪个文件夹。
在 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 示例应用程序)进行更改。
推荐阅读
- outlook - 使用 VSTO(Outlook 客户端不是基于 O365 的 Office 加载项)从 Outlook 项目中提取实体字符串
- django - Django Rest Framework - 前端选择
- python - Python+ocaml TCPServer,TIME_WAIT
- django - 如何查询哪个学生注册了哪个课程?还有哪位老师在教哪门课
- c# - 检索选定 FontFamily 的每个字符
- javascript - Angular - 使字符串变量部分变为粗体
- xcode - SiriKit 意图不适用于本地化
- javascript - Javascript | 堆内存服务器端
- php - Laravel 5.6 Jquery Ajax 500 内部服务器错误
- c# - VB.NET 中的类字段可以不用Getter & Setter 封装吗?