安装之前的环境:
pod: 1.5.3
xcode : 10.1
1. 获取Flutter SDK
通过官网地址:https://flutter.io/sdk-archive/#windows 下载最新的SDK
2. 配置环境变量
进入文件.bash_profile ,如果没有就通过命令创建一个 touch .bash_profile
xia:~ mac$ vim .bash_profile
在文件中加入一行
export PATH={pwd}/flutter/bin:$PATH
其中pwd是下载的flutter所在的文件路径
例如,我的flutter下载之后放在了~/flutter路径下,那么我的就是
export PATH=~/flutter/bin:$PATH
接下来运行source命令,更新配置
xia:~ mac$ source .bash_profile
3. 运行Flutter
执行命令
xia:~ mac$ flutter -h
应该会出现' Welcome to Flutter! '的欢迎语,具体命令输出就不粘贴了
4. 检查Flutter环境
执行命令flutter doctor
xia:~ mac$ flutter doctor
此时我的窗口出现了下面的输出,显示[✗][!]就是错误和警告的地方,接下来按照提示一步一步解决
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, v1.2.1, on Mac OS X 10.14.2 18C54, 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 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
[!] Android Studio (not installed)
[!] VS Code (version 1.28.2)
✗ Flutter extension not installed; install from
https://marketplace.visualstudio.com/items?itemName=Dart-Code.flutter
[✓] Connected device (1 available)
! Doctor found issues in 4 categories.
1. 安装Android Studio、Android SDK、Flutter插件、Dark插件
此时并未安装Android SDK。第一步安装Android Studio之后,启动,会弹出一个框,点击cancel,接下来Android Studio会自动安装SDK。安装好了之后,重启Android Studio,在Android Studio-Preference-Plugins中安装Fluuter和Dark插件
再次执行 flutter doctor 命令
[✓] Flutter (Channel stable, v1.2.1, on Mac OS X 10.14.2 18C54, 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)
✗ 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
[!] Android Studio (version 3.3)
✗ Flutter plugin not installed; this adds Flutter specific functionality.
✗ Dart plugin not installed; this adds Dart specific functionality.
[✓] VS Code (version 1.28.2)
[✓] Connected device (1 available)
安装了Flutter和Dark插件,还是报下边的错误
✗ Flutter plugin not installed; this adds Flutter specific functionality.
✗ Dart plugin not installed; this adds Dart specific functionality.
我的解决办法是执行了一下
flutter doctor -v
报✗ Android licenses not accepted. To resolve this, run: flutter doctor --android-licenses错误的话就执行一下
flutter doctor --android-licenses就好,确认一下协议,输入y确认下就行
2. 安装iOS toolchain
这个比较简单,按照提示步骤一步一步来
[!] 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
在这个过程中我安装libimobiledevice的时候报了下边这个错误,解决办法是执行 pod setup,然后多试几次,多试几次!!!
Cloning into '/Users/mac/Library/Caches/Homebrew/libimobiledevice--git'...
error: RPC failed; curl 18 transfer closed with outstanding read data remaining
fatal: The remote end hung up unexpectedly
fatal: early EOF
fatal: index-pack failed
最后再执行 flutter doctor 输出以下信息,说明全部安装完毕,恭喜~
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, v1.2.1, on Mac OS X 10.14.2 18C54, 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.3)
[✓] VS Code (version 1.28.2)
[✓] Connected device (1 available)
• No issues found!
网友评论