Mac 配置flutter

一、推薦去官網下載,速度並不慢,網址:html

https://flutter.io/setup-macos/android

配置環境變量,這裏筆者使用命令行:macos

vim ~/.bash_profile

添加環境配置vim

export PATH=/你的flutter文件夾所在位置/flutter/bin:$PATH

保存一下,注意若是這個文件不存在,那麼就新建一個。保存完畢以後運行命令:xcode

source ~/.bash_profile

這個時候應該能運行flutter命令了,咱們運行命令行:android-studio

flutter -h

看起來是如此的簡單:可是坑仍是不少的
坑一、.bash_profile文件根本不存在 建立一個bash

touch .bash_profile

添加以下配置app

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

坑二、
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那個是對的,因此一塊兒運行了一下
坑三、ide

$ 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.

根據提示:ui

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
image.png

再次運行

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)

一、Flutter 開發 (1)iOS 下超詳細集成 Flutter
二、flutter環境配置詳解MAC版
三、Macbook pro上安裝Android studio

相關文章
相關標籤/搜索