layout: post
title: "MAC 電腦 Flutter 開發環境的安裝搭建"
date: 2019-04-16
author: "袁鳳鳴"
excerpt: MAC 電腦 Flutter 開發環境的安裝搭建html
categories:
- flutter
tags:
- flutter
mathjax: trueandroid
原文在我博客網站:https://www.yfmingo.cn/2019/04/16/flutter-environment-install/ios
因爲官網下載比較緩慢。能夠下載我百度網盤的JDK
:連接: https://pan.baidu.com/s/1ibnt4PnJgOwFjxNdI3l47Q 提取碼: v2jj 複製這段內容後打開百度網盤手機App,操做更方便哦;
git
Mac下如何安裝JDK:詳細過程能夠參考:http://www.javashuo.com/article/p-ohmavdnz-ee.html
安裝好JDK後須要配置JDK的環境變量:請參考:Mac下如何配置環境變量github
因爲官網下載比較緩慢。能夠下載我百度網盤的Flutter SDK
:https://pan.baidu.com/s/1OQLCy44KBbd1IoBuUzz1eQ
shell
個人 Flutter
安裝在了以下路徑(home
目錄下載新建一個app
文件夾中)android-studio
opne ~/.bash_profile
,加入 Flutter
的安裝路徑
export PATH=/Users/mingo/app/flutter/bin:$PATH
bash
保存關閉 執行:source ~/.bash_profile
app
flutter -h
$ flutter -h Manage your Flutter app development. Common commands: flutter create <output directory> Create a new Flutter project in the specified directory. flutter run [options] Run your Flutter application on an attached device or in an emulator. Usage: flutter <command> [arguments] Global options: -h, --help Print this usage information. -v, --verbose Noisy logging, including all shell commands executed. If used with --help, shows hidden options. -d, --device-id Target device id or name (prefixes allowed). --version Reports the version of this tool. --suppress-analytics Suppress analytics reporting when this command runs. --bug-report Captures a bug report file to submit to the Flutter team. Contains local paths, device identifiers, and log snippets. --packages Path to your ".packages" file. (required, since the current directory does not contain a ".packages" file) Available commands: analyze Analyze the project's Dart code. attach Attach to a running application. bash-completion Output command line shell completion setup scripts. build Flutter build commands. channel List or switch flutter channels. clean Delete the build/ and .dart_tool/ directories. config Configure Flutter settings. create Create a new Flutter project. devices List all connected devices. doctor Show information about the installed tooling. drive Runs Flutter Driver tests for the current project. emulators List, launch and create emulators. format Format one or more dart files. help Display help information for flutter. install Install a Flutter app on an attached device. logs Show log output for running Flutter apps. make-host-app-editable Moves host apps from generated directories to non-generated directories so that they can be edited by developers. packages Commands for managing Flutter packages. precache Populates the Flutter tool's cache of binary artifacts. run Run your Flutter app on an attached device. screenshot Take a screenshot from a connected device. stop Stop your Flutter app on an attached device. test Run Flutter unit tests for the current project. trace Start and stop tracing for a running Flutter app. upgrade Upgrade your copy of Flutter. version List or switch flutter versions. Run "flutter help <command>" for more information about a command. Run "flutter help -v" for verbose help output, including less commonly used options. ╔════════════════════════════════════════════════════════════════════════════╗ ║ 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. ║ ╚════════════════════════════════════════════════════════════════════════════╝
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]
如上:帶❌的就必須按照。帶❗️的就能夠暫時忽略。less
打開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.
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]
按照以下截圖,依次一個個執行如圖命令。
第六個命令 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
項目了。