Mac Flutter安裝與配置

Android唐浮發表於2021-07-14

Mac Flutter安裝與配置

一、獲取Flutter SDK

(1)官網下載適用的SDK:flutter.dev/docs/develo…
(2)解壓SDK安裝包
(3)配置環境變數 命令列輸入:open .bash_profile
然後講地址引用到檔案中

export PATH=`你的flutter所在的資料夾路徑`flutter/bin:$PATH
複製程式碼

由於網路限制,建議把Flutter臨時映象加入,故完整程式碼應該是

#前兩個是映象地址,後面的`/flutter/bin:$PATH`是你clone的倉庫地址,這裡預設就是在你當前的系統路徑中
export PUB_HOSTED_URL=https://pub.flutter-io.cn
export FLUTTER_STORAGE_BASE_URL=https://storage.flutter-io.cn
export PATH=/Users/Talon/Desktop/Tools/flutterSdk/flutter/bin:$PATH
複製程式碼

二、安裝

命令列中執行以下程式碼進行安裝

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.11.6 15G31, locale
    zh-Hans)
 
[!] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
    ! Some Android licenses not accepted.  To resolve this, run: flutter doctor
      --android-licenses
[!] Xcode - develop for iOS and macOS (Xcode 8.2.1)
    ✗ Flutter requires a minimum Xcode version of 9.0.0.
      Download the latest version or update via the Mac App Store.
    ! CocoaPods out of date (1.6.0 is recommended).
        CocoaPods is used to retrieve the iOS and macOS platform side's plugin
        code that responds to your plugin usage on the Dart side.
        Without CocoaPods, plugins will not work on iOS or macOS.
        For more info, see https://flutter.dev/platform-plugins
      To upgrade:
        brew upgrade cocoapods
        pod setup
[✗] iOS tools - develop for iOS devices
    ✗ 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.2)
    ✗ Flutter plugin not installed; this adds Flutter specific functionality.
    ✗ Dart plugin not installed; this adds Dart specific functionality.
[!] IntelliJ IDEA Community Edition (version 2018.2.4)
    ✗ 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 6 categories.
複製程式碼

上面的資訊可以看出

  1. flutter安裝的版本
  2. Flutter執行所需的Android工具鏈,有些許可證沒有接受
  3. XCode需要更新,IOS先跳過
  4. AS和IntelliJ 外掛沒有安裝
  5. 沒有裝置連結

解決: (1)接受許可

flutter doctor --android-licenses
複製程式碼

一路輸入 Y

(2)安裝AS外掛,安裝完後重啟AS

1.png

並勾選 File>Settings>Plugs>Android APK Support,確認並重啟AS

三、第一個flutter程式

  1. 選擇File>New Flutter Project
  2. 建立完成之後,啟動即可。

相關文章