1.下载Flutter SDK,zip包: (stable版本),解压。
https://flutter.dev/docs/get-started/install/macos
2.配置环境变量(我是将flutter解压于Documents下面的)
vim ~/.bash_profile ,键入 i (insert) 编写:
export PATH=/Users/***/flutter/bin:$PATH
export PUB_HOSTED_URL=https://pub.flutter-io.cn
export FLUTTER_STORAGE_BASE_URL=https://storage.flutter-io.cn
按ESC键,输入:wq,就可以保存退出了
source ~/.bash_profile
3.flutter doctor 详细版: flutter doctor -v
会出现以下问题:
[✓] Flutter (Channel stable, v1.12.13+hotfix.8, on Mac OS X 10.15 19A583, locale
zh-Hans-CN)
• Flutter version 1.12.13+hotfix.8 at /Users/fengfal/Documents/flutter
• Framework revision 0b8abb4724 (5 weeks ago), 2020-02-11 11:44:36 -0800
• Engine revision e1e6ced81d
• Dart version 2.7.0
[!] Android toolchain - develop for Android devices (Android SDK version 29.0.3)
• Android SDK at /Users/fengfal/Library/Android/sdk
• Android NDK location not configured (optional; useful for native profiling
support)
• Platform android-R, build-tools 29.0.3
• Java binary at: /Applications/Android
Studio.app/Contents/jre/jdk/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build
1.8.0_212-release-1586-b4-5784211)
✗ 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.
[!] 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
sudo xcodebuild -runFirstLaunch
• CocoaPods version 1.8.4
[✓] Android Studio (version 3.6)
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin version 44.0.2
• Dart plugin version 192.7761
• Java version OpenJDK Runtime Environment (build
1.8.0_212-release-1586-b4-5784211)
[✓] VS Code (version 1.43.0)
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension version 3.8.1
[!] Connected device
! No devices available
! Doctor found issues in 3 categories.
3.1: 问题一
[!] Android toolchain - develop for Android devices (Android SDK version 29.0.3)
• Android SDK at /Users/fengfal/Library/Android/sdk
• Android NDK location not configured (optional; useful for native profiling
support)
• Platform android-R, build-tools 29.0.3
• Java binary at: /Applications/Android
Studio.app/Contents/jre/jdk/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build
1.8.0_212-release-1586-b4-5784211)
✗ 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.
解决方法:
第一步: I had this issue after installed on my KUbuntu.
You need to openAndroidStudiothen go toTools->SDK Managerthen go toSDK Toolstab, uncheck the option Hide Obsolete Packages
You will see the option ofAndroid SDK Tools (Obsolete), check the option and continue the process download and installation.
第二步:flutter doctor --android-licenses 全是y
3.2:问题二:
[!] 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
sudo xcodebuild -runFirstLaunch
• CocoaPods version 1.8.4
解决方法:
sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer
sudo xcodebuild -runFirstLaunch
因为我这边是iOS开发环境都已经配置好了,包括cocoapods、xcode都已经安装好了。所以iOS环境比较轻松。