Flutter入门学习(一)在macOS上搭建Flutter开发环境

开发环境

Mac M1
Xcode
Android Studio
VSCode

配置Flutter开发环境

按照https://flutterchina.club/步骤操作即可。

如果本地没有 iOS 和 Android 开发环境,建议先安装 Xcode 和 Android Studio,我本地 iOS 和 Android 的开发环境都是没问题的,Visual Studio Code 也没啥问题,直接按照网上提供的步骤进行环境配置。

以下是我在 M1 上搭建Flutter开发环境遇到的问题以及解决方法

➜  Documents flutter doctor                                     
Doctor summary (to see all details, run flutter doctor -v):
[] Flutter (Channel stable, 3.0.0, on macOS 12.2 21D49 darwin-arm (Rosetta), locale zh-Hans-CN)
[!] Android toolchain - develop for Android devices (Android SDK version 32.1.0-rc1)
    ✗ cmdline-tools component is missing
      Run `path/to/sdkmanager --install "cmdline-tools;latest"`
      See https://developer.android.com/studio/command-line for more details.
    ✗ Android license status unknown.
      Run `flutter doctor --android-licenses` to accept the SDK licenses.
      See https://flutter.dev/docs/get-started/install/macos#android-setup for more details.
[] Xcode - develop for iOS and macOS (Xcode 13.2.1)
[] Chrome - develop for the web
[!] Android Studio
    ✗ Unable to find bundled Java version.
[] Android Studio (version 2021.1)
[] VS Code (version 1.67.1)
[] Connected device (2 available)
[] HTTP Host Availability

! Doctor found issues in 2 categories.

cmdline-tools component is missingAndroid license status unknown

打开Android Studio, Android Studio -> Preferences -> Appearance & Behavior -> System Settings -> Android SDK 下,勾选 Andriod SDK Command-line Tools(latest),然后Apply。

如下图:
请添加图片描述

Unable to find bundled Java version

原因时我本地安装了Android Studio 和 Android Studio Preview,我把 Android Studio Preview 卸载了重新 flutter doctor,问题解决了。

[!] Android toolchain - develop for Android devices (Android SDK version 32.1.0-rc1) ! Some Android licenses not accepted. To resolve this, run: flutter doctor --android-licenses

终端执行 flutter doctor --android-licenses,一路 y 即可。

✗ Due to an error, the doctor check did not complete. If the error message below is not helpful, please let us know about this issue at https://github.com/flutter/flutter/issues. ✗ HandshakeException: Connection terminated during handshake

这个错误我没管…

最后执行 flutter doctor 效果如下:

➜  Documents flutter doctor                   
Doctor summary (to see all details, run flutter doctor -v):
[] Flutter (Channel stable, 3.0.0, on macOS 12.2 21D49 darwin-arm (Rosetta), locale zh-Hans-CN)
[] Android toolchain - develop for Android devices (Android SDK version 32.1.0-rc1)
[] Xcode - develop for iOS and macOS (Xcode 13.2.1)
[] Chrome - develop for the web
[] Android Studio (version 2021.1)
[] VS Code (version 1.67.1)
[] Connected device (2 available)
HTTP Host availability check is taking a long time...[] HTTP Host Availability (the doctor check crashed)
    ✗ Due to an error, the doctor check did not complete. If the error message below is not helpful, please let us know
      about this issue at https://github.com/flutter/flutter/issues.
    ✗ HandshakeException: Connection terminated during handshake

! Doctor found issues in 1 category.

之后按照官网指导,继续做就可以了。

配置编辑器

VSCode 安装插件 Flutter 即可。
请添加图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Morris_

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值