flutter安装

参考文档:

https://flutterchina.club/setup-macos/

https://segmentfault.com/a/1190000014845833

1、首先安装flutterSDK,因为国内镜像的原因可能需要更换下镜像信息(镜像更新关注:https://flutter.dev/community/china

export PUB_HOSTED_URL=https://pub.flutter-io.cn

export FLUTTER_STORAGE_BASE_URL=https://storage.flutter-io.cn

git clone -b dev https://github.com/flutter/flutter.git

export PATH="PWD/flutter/bin:PATH"

cd ./flutter

flutter doctor

flutter doctor 会帮助检测所需要的工具是否齐全

注意如果出现flutter命令失效 需要从新写入flutter bin路径信息

安装成功时候回显示:

╔════════════════════════════════════════════════════════════════════════════╗

║ Welcome to Flutter! - https://flutter.io

║ ║

║ 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. ║

╚════════════════════════════════════════════════════════════════════════════╝

问题:

Doctor summary (to see all details, run flutter doctor -v):

[✓] Flutter (Channel dev, v1.4.6, on Mac OS X 10.14.4 18E226, 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](https://developer.android.com/studio/index.html)

  On first launch it will assist you in installing the Android SDK components.

  (or visit [https://flutter.io/setup/#android-setup](https://flutter.io/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.

[!] iOS toolchain - develop for iOS devices (Xcode 10.1)

✗ 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

✗ Brew can be used to install tools for iOS device development.

  Download brew at [https://brew.sh/](https://brew.sh/).

[!] Android Studio (not installed)

[!] Connected device

! No devices available

! Doctor found issues in 4 categories.

appledeMacBook-Pro-41:flutter apple$

这里来解决我的问题

问题1 Android toolchain - develop for Android devices

这里显然是安卓开发工具没有安装的问题,所以我们去下载java JDK和安卓studio 因为教程很多,所以这里只简单描述了

1、安装java JDK

下载java sdk https://www.oracle.com下载jdk 无脑安装,然后.bash_profile环境变量配置(根据你自己的环境变量配置信息来)

JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.7.0_71.jdk/Contents/Home PATH=JAVA_HOME/bin:PATH:. CLASSPATH=JAVA_HOME/lib/tools.jar:JAVA_HOME/lib/dt.jar:. export JAVA_HOME export PATH export CLASSPATH

注意source .bash_profile让配置生效,然后java -v 查看版本信息

appledeMacBook-Pro-41:~ apple$ java -version

java version "1.8.0_201"

Java(TM) SE Runtime Environment (build 1.8.0_201-b09)

Java HotSpot(TM) 64-Bit Server VM (build 25.201-b09, mixed mode)

appledeMacBook-Pro-41:~ apple$

如上输出 则说明你安装jdk成功

2、安装android studio

下载http://www.android-studio.org/ 选择Mac版本 然后无脑式下一步安装 注意配置

选择安装标准版本,但是此处回关联安卓SDK下载配置。也可以手动去下载配置安卓sdk信息,如果查找有问题需要制定安卓HOME路径

这里列举下flutter的所有路径信息:(可以对照自己的路径进行修改)

export PATH=/Users/用户名/Documents/flutter/flutter/bin:$PATH

export ANDROID_HOME="/Users/用户名/Documents/android_sdk" //android sdk目录,替换为你自己的即可

export PATH={PATH}:{ANDROID_HOME}/tools

export PATH={PATH}:{ANDROID_HOME}/platform-tools

export PUB_HOSTED_URL=https://pub.flutter-io.cn

export FLUTTER_STORAGE_BASE_URL=https://storage.flutter-io.cn

问题2就不说了。注意安装brew信息。然后根据brew安装其他需要工具

注意这里https://brew.sh/. brew的安装可能遇到xcode的路径配置信息问题

Error downloading updates.

==> /usr/bin/sudo /bin/rm -f /tmp/.com.apple.dt.CommandLineTools.installondemand.in-progress

==> /usr/bin/sudo /usr/bin/xcode-select --switch /Library/Developer/CommandLineTools

这是因为Xcode安装位置变更引起的,我们需要手动变更下安装配置路径

首先查看你的正确路径

xcode-select -p

/Applications/Xcode.app/Contents/Developer

解决1 sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer 最简单的就是强行指定,这方法我没用过。我用的方法二

解决2 获取安装文件 https://raw.githubusercontent.com/Homebrew/install/master/install Mac下touch install文件,复制其中的内容到文件中,然后替换其中的/Library/Developer/CommandLineTools为正确路径,然后保存执行 ruby -e "$(cat install)”安装命令

安装完成再一次运行出现错误信息:

appledeMacBook-Pro-41:~ apple$ flutter doctor

Doctor summary (to see all details, run flutter doctor -v):

[✓] Flutter (Channel dev, v1.4.6, on Mac OS X 10.14.4 18E226, locale zh-Hans-CN)

[!] Android toolchain - develop for Android devices (Android SDK version 28.0.3)

✗ Android licenses not accepted.  To resolve this, run: flutter doctor --android-licenses

[✓] iOS toolchain - develop for iOS devices (Xcode 10.1)

[!] Android Studio (version 3.2)

✗ Flutter plugin not installed; this adds Flutter specific functionality.

✗ Dart plugin not installed; this adds Dart specific functionality.

[!] Connected device

! No devices available

! Doctor found issues in 3 categories.

appledeMacBook-Pro-41:~ apple$

问题1 按照要求运行

输入 flutter doctor --android-licenses,接下来所有的输入 y 就可以了

再次flutter doctor 问题解决部分 但是还有剩下的如下:

appledeMacBook-Pro-41:~ apple$ flutter doctor

Doctor summary (to see all details, run flutter doctor -v):

[✓] Flutter (Channel dev, v1.4.6, on Mac OS X 10.14.4 18E226, locale zh-Hans-CN)

[✓] Android toolchain - develop for Android devices (Android SDK version 28.0.3)

[✓] iOS toolchain - develop for iOS devices (Xcode 10.1)

[!] Android Studio (version 3.2)

✗ Flutter plugin not installed; this adds Flutter specific functionality.

✗ Dart plugin not installed; this adds Dart specific functionality.

[!] Connected device

! No devices available

! Doctor found issues in 2 categories.

这问题是安卓studio插件问题 打开安卓studio 配置上选择插件

[图片上传失败...(image-811353-1624439961629)]

打开android studio, 打开plugins检索flutter(注意这里需要翻墙有时候)

检索结果安装

image.png

安装完成重新启动安卓studio

再次flutter doctor

appledeMacBook-Pro-41:~ apple$ flutter doctor

Doctor summary (to see all details, run flutter doctor -v):

[✓] Flutter (Channel dev, v1.4.6, on Mac OS X 10.14.4 18E226, locale zh-Hans-CN)

[✓] Android toolchain - develop for Android devices (Android SDK version 28.0.3)

[✓] iOS toolchain - develop for iOS devices (Xcode 10.1)

[✓] Android Studio (version 3.2)

[!] Connected device

! No devices available

appledeMacBook-Pro-41:~ apple$

如此配置已经完成了!!

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

推荐阅读更多精彩内容