1、推荐去官网下载,速度并不慢,网址:
https://flutter.io/setup-macos/
配置环境变量,这里笔者使用命令行:
vim ~/.bash_profile
添加环境配置
export PATH=/你的flutter文件夹所在位置/flutter/bin:$PATH
保存一下,注意如果这个文件不存在,那么就新建一个。保存完毕之后运行命令:
source ~/.bash_profile
这个时候应该能运行flutter命令了,我们运行命令行:
flutter -h
看起来是如此的简单:但是坑还是很多的
坑1、.bash_profile文件根本不存在 创建一个
touch .bash_profile
添加如下配置
export PUB_HOSTED_URL=https://pub.flutter-io.cn
export FLUTTER_STORAGE_BASE_URL=https://storage.flutter-io.cn
export PATH=/Users/ruihe/Downloads/flutter/bin:$PATH
坑2、
MacBook-Pro:~ xxxx$ flutter -h
-bash: flutter: command not found
下载下来之后把文件复制到其它里面去了 运行source ~/.bash_profile
一直抱这个错,纠结了好久,最后重新下载了一根直接把这个下载的路径/Users/xxxx/Downloads/设置了进去,
xxxxxx$ open ~/.bash_profile
xxxxxx$ source .bash_profile
xxxxxx$ source ~/.bash_profile
主要不知道2和3那个是对的,所以一起运行了一下
坑3、
$ flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, v1.7.8+hotfix.4, on Mac OS X 10.14.5 18F132, 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 installation is incomplete; a full installation is necessary for iOS
development.
Download at: https://developer.apple.com/xcode/download/
Or install Xcode via the App Store.
Once installed, run:
sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer
[!] iOS tools - develop for iOS devices
✗ Verify that all connected devices have been paired with this computer in
Xcode.
If all devices have been paired, libimobiledevice and ideviceinstaller may
require updating.
To update with Brew, run:
brew update
brew uninstall --ignore-dependencies libimobiledevice
brew uninstall --ignore-dependencies usbmuxd
brew install --HEAD usbmuxd
brew unlink usbmuxd
brew link usbmuxd
brew install --HEAD libimobiledevice
brew install ideviceinstaller
[!] Android Studio (not installed)
[!] Connected device
! No devices available
! Doctor found issues in 5 categories.
根据提示:
Once installed, run:
sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer
To update with Brew, run:
brew update
brew uninstall --ignore-dependencies libimobiledevice
brew uninstall --ignore-dependencies usbmuxd
brew install --HEAD usbmuxd
brew unlink usbmuxd
brew link usbmuxd
brew install --HEAD libimobiledevice
brew install ideviceinstaller
1. 下载AndroidStudio及SDK
下载地址:http://www.android-studio.org
1⃣️下载AndroidStudio
选择Mac版本下载
安装Android Studio详情
完成之后
再次运行 flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, v1.7.8+hotfix.4, on Mac OS X 10.14.5 18F132, locale
zh-Hans-CN)
[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
[✓] Xcode - develop for iOS and macOS (Xcode 10.3)
[✓] iOS tools - develop for iOS devices
[!] Android Studio (version 3.4)
✗ Flutter plugin not installed; this adds Flutter specific functionality.
✗ Dart plugin not installed; this adds Dart specific functionality.
[✓] Connected device (1 available)
安装flutter 、dart 重启Android Studio
再次运行
flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, v1.7.8+hotfix.4, on Mac OS X 10.14.5 18F132, locale
zh-Hans-CN)
[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
[✓] Xcode - develop for iOS and macOS (Xcode 10.3)
[✓] iOS tools - develop for iOS devices
[✓] Android Studio (version 3.4)
[✓] Connected device (1 available)
1、Flutter 开发 (1)iOS 下超详细集成 Flutter
2、flutter环境配置详解MAC版
3、Macbook pro上安装Android studio