layout: post
title: "MAC 电脑 Flutter 开发环境的安装搭建"
date: 2019-04-16
author: "袁凤鸣"
excerpt: MAC 电脑 Flutter 开发环境的安装搭建
categories:
- flutter
tags:
- flutter
mathjax: true
- content
{:toc}
原文在我博客网站:https://www.yfmingo.cn/2019/04/16/flutter-environment-install/
0x01-1、2-1 Flutter开发环境的安装-01:
0x01-2、2-1 Flutter开发环境的安装-02:
0x02、JDK 安装:
由于官网下载比较缓慢。可以下载我百度网盘的JDK
:链接: https://pan.baidu.com/s/1ibnt4PnJgOwFjxNdI3l47Q 提取码: v2jj 复制这段内容后打开百度网盘手机App,操作更方便哦;
Mac下如何安装JDK:详细过程可以参考:https://www.cnblogs.com/quickcodes/p/5127101.html
安装好JDK后需要配置JDK的环境变量:请参考:Mac下如何配置环境变量
0x03、Flutter JDK 安装:
由于官网下载比较缓慢。可以下载我百度网盘的Flutter SDK
:https://pan.baidu.com/s/1OQLCy44KBbd1IoBuUzz1eQ
我的 Flutter
安装在了如下路径(home
目录下载新建一个app
文件夹中)
配置环境变量:
-
在终端执行
opne ~/.bash_profile
,加入Flutter
的安装路径-
export PATH=/Users/mingo/app/flutter/bin:$PATH
保存关闭 执行:
source ~/.bash_profile
-
-
这个时候应该能运行flutter命令了,我们运行命令行:
flutter -h
- 出现如下:
$ flutter -h
Manage your Flutter app development.
Common commands:
flutter create
0x04、Flutter 检查环境:
0x04-1、Flutter 提供了 检查环境 命令 flutter doctor
# mingo @ 192 in ~ [12:59:45]
$ flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, v1.2.1, on Mac OS X 10.13.6 17G4015, 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.io/setup/#android-setup for detailed instructions).
If 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 9.4.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
[!] Android Studio (not installed)
[!] IntelliJ IDEA Ultimate Edition (version 2018.3.5)
✗ 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 5 categories.
# mingo @ 192 in ~ [13:03:33]
如上:带❌的就必须按照。带❗️的就可以暂时忽略。
0x04-2、安装 Android Studio 和 VS Code
打开android studio
, 打开plugins
,安装flutter
输入flutter搜索,点击中间的 Search in repositories
点击install
,顺利的话安装完毕之后重启android studio
再次运行
然后在 flutter doctor
:
# mingo @ 192 in ~ [13:03:33]
$ flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, v1.2.1, on Mac OS X 10.13.6 17G4015, 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 9.4.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
[✓] Android Studio (version 3.3)
[!] IntelliJ IDEA Ultimate Edition (version 2018.3.5)
✗ 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 4 categories.
0x04-3、执行flutter doctor --android-licenses
同意相关协议
# mingo @ 192 in ~ [13:22:07]
$ flutter doctor --android-licenses
.
.
.此处 N 多信息,都是相关协议文件,一路 y 即可。
.
.
---------------------------------------
Accept? (y/N): y
All SDK package licenses accepted
# mingo @ 192 in ~ [13:22:48]
$ flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, v1.2.1, on Mac OS X 10.13.6 17G4015, locale zh-Hans-CN)
[✓] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
[!] iOS toolchain - develop for iOS devices (Xcode 9.4.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
[✓] Android Studio (version 3.3)
[!] IntelliJ IDEA Ultimate Edition (version 2018.3.5)
✗ 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.
# mingo @ 192 in ~ [1:02:09]
0x04-4、解决 iOS 环境
按照如下截图,依次一个个执行如图命令。
第六个命令 brew install ios-deploy
安装完如下:
# mingo @ 192 in ~ [13:49:02]
$ brew install ios-deploy
==> Downloading https://homebrew.bintray.com/bottles/ios-deploy-1.9.4.high_sierra.bottle.tar
######################################################################## 100.0%
==> Pouring ios-deploy-1.9.4.high_sierra.bottle.tar.gz
/usr/local/Cellar/ios-deploy/1.9.4: 7 files, 157.2KB
# mingo @ 192 in ~ [13:58:36]
在 检查环境
# mingo @ 192 in ~ [0:35:18]
$ flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, v1.2.1, on Mac OS X 10.13.6 17G4015, locale zh-Hans-CN)
[✓] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
[✓] iOS toolchain - develop for iOS devices (Xcode 9.4.1)
[✓] Android Studio (version 3.3)
[!] IntelliJ IDEA Ultimate Edition (version 2018.3.5)
✗ Flutter plugin not installed; this adds Flutter specific functionality.
✗ Dart plugin not installed; this adds Dart specific functionality.
[✓] VS Code (version 1.33.1)
[✓] Connected device (2 available)
! Doctor found issues in 1 category.
# mingo @ 192 in ~ [0:36:26]
因为不需要使用 IntelliJ IDEA
来开发,如果你电脑中没有安装IntelliJ IDEA
是不会提示这个警告的,所以可以先不管这个栏目的❗️和 ❌
到此,Flutter
环境搭建完成,可以用 Android Studio
,新建第一个 Flutter
项目了。