Mac 搭建 Flutter 开发环境

Flutter 下载

  • Flutter 官网
    有很多种方式,我是用的git下载的,比较方便,其他食用方式萝卜青菜各有所爱哈
$ git clone -b master https://github.com/flutter/flutter.git
$ ./flutter/bin/flutter --version 
$ git clone -b master https://github.com/flutter/flutter.git
Cloning into 'flutter'...
remote: Enumerating objects: 7, done.
remote: Counting objects: 100% (7/7), done.
remote: Compressing objects: 100% (6/6), done.
remote: Total 173520 (delta 0), reused 3 (delta 0), pack-reused 173513
Receiving objects: 100% (173520/173520), 62.81 MiB | 1.48 MiB/s, done.
Resolving deltas: 100% (132713/132713), done.
Checking out files: 100% (3446/3446), done.

bogon:Flutter mac$ ./flutter/bin/flutter --version
Downloading Dart SDK from Flutter engine de350c4cbb4aa3d4b3258fb8646f8723d3991096...
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:--  0:03:00 --:--:--     0
curl: (56) LibreSSL SSL_read: SSL_ERROR_SYSCALL, errno 54

Failed to retrieve the Dart SDK from: https://storage.googleapis.com/flutter_infra/flutter/de350c4cbb4aa3d4b3258fb8646f8723d3991096/dart-sdk-darwin-x64.zip
If you're located in China, please see this page:
  https://flutter.dev/community/china

  • 镜像
bogon:Flutter mac$ export PUB_HOSTED_URL=https://pub.flutter-io.cn
bogon:Flutter mac$ export FLUTTER_STORAGE_BASE_URL=https://storage.flutter-io.cn

  • 继续
$ ./flutter/bin/flutter --version
Downloading Dart SDK from Flutter engine de350c4cbb4aa3d4b3258fb8646f8723d3991096...
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  121M  100  121M    0     0  35.8M      0  0:00:03  0:00:03 --:--:-- 35.8M
Building flutter tool...
Flutter 1.7.4-pre.69 • channel master • https://github.com/flutter/flutter.git
Framework • revision d6425a2179 (65 minutes ago) • 2019-06-11 21:54:55 -0400
Engine • revision de350c4cbb
Tools • Dart 2.3.3 (build 2.3.3-dev.0.0 b37aa3b036)

  ╔════════════════════════════════════════════════════════════════════════════╗
  ║                 Welcome to Flutter! - https://flutter.dev                  ║
  ║                                                                            ║
  ║ The Flutter tool anonymously reports feature usage statistics and crash    ║
  ║ reports to Google in order to help Google contribute improvements to       ║
  ║ Flutter over time.                                                         ║
  ║                                                                            ║
  ║ Read about data we send with crash reports:                                ║
  ║ https://github.com/flutter/flutter/wiki/Flutter-CLI-crash-reporting        ║
  ║                                                                            ║
  ║ See Google's privacy policy:                                               ║
  ║ https://www.google.com/intl/en/policies/privacy/                           ║
  ║                                                                            ║
  ║ Use "flutter config --no-analytics" to disable analytics and crash         ║
  ║ reporting.                                                                 ║
  ╚════════════════════════════════════════════════════════════════════════════╝


  • 添加flutter相关工具到path中:
$ export PATH=`pwd`/flutter/bin:$PATH

** 查看缺失环节

$ flutter doctor
[✓] Flutter (Channel master, v1.7.4-pre.69, on Mac OS X 10.14 18A391, locale
    zh-Hans-CN)
[✗] Android toolchain - develop for Android devices
    ✗ Unable to locate Android SDK.
      Install Android Studio from:
      https://developer.android.com/studio/index.html
      On first launch it will assist you in installing the Android SDK
      components.
      (or visit https://flutter.dev/setup/#android-setup for detailed
      instructions).
      If the Android SDK has been installed to a custom location, set
      ANDROID_HOME to that location.
      You may also want to add it to your PATH environment variable.

[✓] Xcode - develop for iOS and macOS (Xcode 10.1)
[✗] iOS tools - develop for iOS devices
    ✗ libimobiledevice and ideviceinstaller are not installed. To install with
      Brew, run:
        brew update
        brew install --HEAD usbmuxd
        brew link usbmuxd
        brew install --HEAD libimobiledevice
        brew install ideviceinstaller
    ✗ ios-deploy not installed. To install:
        brew install ios-deploy
[!] Android Studio (not installed)
[✓] Connected device (1 available)

! Doctor found issues in 3 categories.

** 解决xx

- brew install --HEAD usbmuxd

遇到的问题:

'''Error: Your Xcode (10.1) is too outdated.
Please update to Xcode 10.2.1 (or delete it).
Xcode can be updated from the App Store.'''

升级xcode,对系统有依赖的话,也要升级下系统

  • 如果出现'[!] Android Studio (version 3.4)
    ✗ Flutter plugin not installed; this adds Flutter specific functionality.
    ✗ Dart plugin not installed; this adds Dart specific functionality.'

打开android studio 的偏好设置,搜索 flutter 下载(dart 会一起下的)


image.png

找不到的话,记得在这里取消勾选框,记得apply 。亲测有效

image.png
  • 协议没找到
[!] Android toolchain - develop for Android devices (Android SDK version 29.0.0)
    ✗ Android license status unknown.
      Try re-installing or updating your Android SDK Manager.
      See https://developer.android.com/studio/#downloads or visit https://flutter.dev/setup/#android-setup
      for detailed instructions.

解决方法:

$ flutter doctor --android-licenses
A newer version of the Android SDK is required. To update, run:
/Users/mac/Library/Android/sdk/tools/bin/sdkmanager --update
  • sdk 位置错了
[✗] Android toolchain - develop for Android devices
    ✗ ANDROID_HOME = /Users/mac/Library/Application\ Support/AndroidStudio3.4/sdk
      but Android SDK not found at this location.

解决:

$ flutter config --android-sdk /Users/mac/Library/Android/sdk
  • app 位置错了
[!] Android Studio
    ✗ Flutter plugin not installed; this adds Flutter specific functionality.
    ✗ Dart plugin not installed; this adds Dart specific functionality.
    ✗ Android Studio not found at /Users/mac/Library/Android/sdk/Contents

解决:

$ flutter config --android-studio-dir /Applications/Android\ Studio.app 
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 202,332评论 5 475
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 84,930评论 2 379
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 149,204评论 0 335
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 54,348评论 1 272
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 63,356评论 5 363
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 48,447评论 1 281
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 37,862评论 3 394
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 36,516评论 0 256
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 40,710评论 1 295
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 35,518评论 2 318
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 37,582评论 1 329
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 33,295评论 4 318
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 38,848评论 3 306
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 29,881评论 0 19
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 31,121评论 1 259
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 42,737评论 2 349
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 42,280评论 2 341

推荐阅读更多精彩内容