一美浦、安裝Homebrew 官網(wǎng):https://brew.sh/index_zh-cn
1、刪除舊的homebrew
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/uninstall)"
2项栏、安裝新的homebrew
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontt.com/Homebrew/install/master/install)"
errno 54 解決方法
報(bào)錯(cuò)信息:fatal: unable to access 'https://github.com/Homebrew/brew/': LibreSSL SSL_read: SSL_ERROR_SYSCALL, errno 54
1浦辨、 Ping github.com
PING github.com (13.229.188.59): 56 data bytes
Request timeout for icmp_seq 0
Request timeout for icmp_seq 1
Request timeout for icmp_seq 2
2、 修改 hosts 配置
在最下面添加 192.30.253.113 github.com 即可
3忘嫉、再次ping github.com
64 bytes from 192.30.253.113: icmp_seq=0 ttl=48 time=351.320 ms
64 bytes from 192.30.253.113: icmp_seq=1 ttl=48 time=274.265 ms
64 bytes from 192.30.253.113: icmp_seq=2 ttl=48 time=294.453 ms
3荤牍、 再次執(zhí)行安裝命令
remote: Enumerating objects: 125670, done.
remote: Total 125670 (delta 0), reused 0 (delta 0), pack-reused 125670
Receiving objects: 100% (125670/125670), 29.80 MiB | 29.00 KiB/s, done.
Resolving deltas: 100% (92120/92120), done.
出現(xiàn) ==> Installation successful! 即安裝完成
二、下載Flutter SDK
1庆冕、官網(wǎng)地址 https://flutter.dev/
(或使用 git clone -b beta https://github.com/flutter/flutter.git 命令)
2、現(xiàn)在之后解壓(目錄根據(jù)自己喜好劈榨,本文目錄為 /opt/flutter)
3访递、設(shè)置環(huán)境變量
a)設(shè)置鏡像
export PUB_HOSTED_URL=https://pub.flutter-io.cn
export FLUTTER_STORAGE_BASE_URL=https://storage.flutter-io.cn
b)設(shè)置 Flutter 環(huán)境配置(/.bash profile)
export PATH=/opt/flutter/bin:$PATH
c)配置完成 重啟終端 或 source ~/.bash_profile
三、執(zhí)行 flutter doctor 檢測(cè)缺失
從一下信息可以看出除有了基本的flutterSDK之外 android與iOS環(huán)境均無(wú)
Doctor summary (to see all details, run flutter doctor -v):
[?] Flutter (Channel stable, v1.5.4-hotfix.2, on Mac OS X 10.14.4 18E2035,
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.
[!] iOS toolchain - develop for iOS devices
? 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
? 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.4)
? Flutter plugin not installed; this adds Flutter specific functionality.
? Dart plugin not installed; this adds Dart specific functionality.
[!] Connected device
! No devices available
四同辣、安裝Android Studio
官網(wǎng)地址:[https://developer.android.google.cn/studio]
1拷姿、配置android環(huán)境變量
第一行:androidsdk路徑
第二行:android模擬器路徑
第三行:android tools路徑
第四行:android 平臺(tái)工具路徑
.bash_profile
export ANDROID_HOME=/opt/Android/sdk
export PATH=${PATH}:${ANDROID_HOME}/emulator
export PATH=${PATH}:${ANDROID_HOME}/tools
export PATH=${PATH}:${ANDROID_HOME}/platform-tools
執(zhí)行flutter doctor命令出現(xiàn)以下提示 說(shuō)明成功
[?] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
2、安裝android studio 插件以解決報(bào)錯(cuò):
[!] Android Studio (version 3.4)
? Flutter plugin not installed; this adds Flutter specific functionality.
? Dart plugin not installed; this adds Dart specific functionality.
1旱函、打開(kāi)android studio 在偏好設(shè)置里 配置sdk
2响巢、在偏好設(shè)置里 找到Plugins 搜索 Flutter 點(diǎn)擊 install (如果報(bào)網(wǎng)絡(luò)錯(cuò)誤 則去掉設(shè)置里Updates選項(xiàng)中的 Use secure connection 重啟
還不行的話就只能去 [https://plugins.jetbrains.com/idea]下載了)
3、配置android模擬器
a)點(diǎn)擊設(shè)備管理
b)創(chuàng)建新設(shè)備
c)點(diǎn)擊下一步 選擇Pie 下載
d)重命名設(shè)備(便于命令執(zhí)行) 點(diǎn)擊Finish完成
4棒妨、配置虛擬機(jī)加速
a)到之前的androidsdk存放目錄下/opt/Android/sdk/extras/intel/Hardware_Accelerated_Execution_Man
ager/ 找到IntelHAXM_7.5.1.dmg安裝文件
b)點(diǎn)擊安裝
c)執(zhí)行命令 kextstat | grep intel 查看是否完成踪古。
com.intel.kext.intelhaxm (7.5.1) D0CB88-1F62-33B1-BE6B-B557607B <8 6 5 3 1>
3、配置iOS環(huán)境 (按命令順序執(zhí)行下載安裝)
? 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
五券腔、flutter doctor 檢測(cè) 以下為配置完成 如果有打叉的選項(xiàng)伏穆,根據(jù)其提供命令安裝相應(yīng)文件
Doctor summary (to see all details, run flutter doctor -v):
[?] Flutter (Channel stable, v1.5.4-hotfix.2, on Mac OS X 10.14.4 18E2035, locale zh-Hans-CN)
[?] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
[?] iOS toolchain - develop for iOS devices (Xcode 10.3)
[?] Android Studio (version 3.5)
[!] Connected device
六、新建flutter doctor 工程,打開(kāi)模擬器纷纫,點(diǎn)擊運(yùn)行枕扫,運(yùn)行成功。配置完成
image.png