主要參考flutter中文官方,結(jié)合自己操作過程的問題整理的這篇文章
使用鏡像
由于在國內(nèi)訪問Flutter有時可能會受到限制琳状,F(xiàn)lutter官方為中國開發(fā)者搭建了臨時鏡像,大家可以將如下環(huán)境變量加入到用戶環(huán)境變量中:
export PUB_HOSTED_URL=https://pub.flutter-io.cn
export FLUTTER_STORAGE_BASE_URL=https://storage.flutter-io.cn
注意: 此鏡像為臨時鏡像,并不能保證一直可用,讀者可以參考詳情請參考 Using Flutter in China 以獲得有關(guān)鏡像服務(wù)器的最新動態(tài)。
獲取Flutter SDK
1.去Flutter官網(wǎng)下載官網(wǎng)地址 或者 去github上下載git地址
2.解壓安裝包到你想安裝的目錄,如:
cd ~/Users/#自己的賬戶名#
unzip ~/Downloads/flutter_macos_v0.5.1-beta.zip #下載的zip文件#
3.添加flutter相關(guān)工具到path中:(在步驟2當(dāng)前路徑下)
export PATH=`pwd`/flutter/bin:$PATH
運(yùn)行 flutter doctor
[?] Flutter (Channel stable, v1.0.0, on Mac OS X 10.13.6 17G4015, locale
zh-Hans-CN)
[!] Android toolchain - develop for Android devices
? No valid Android SDK platforms found in
/Users/chengguangfa/Library/Android/sdk/platforms. Directory was empty.
[!] iOS toolchain - develop for iOS devices (Xcode 10.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
[?] Android Studio (version 3.3)
? Flutter plugin not installed; this adds Flutter specific functionality.
? Dart plugin not installed; this adds Dart specific functionality.
[!] Connected device
! No devices available
[?]
表示沒有問題, ?
表示有錯誤需要按照提示去安裝
1.先修復(fù)iOS toolchain
問題
[!] iOS toolchain - develop for iOS devices (Xcode 10.1)
? libimobiledevice and ideviceinstaller are not installed. To install with
Brew, run:
brew update
#step1
brew install --HEAD usbmuxd
#step2
brew link usbmuxd
#step3
brew install --HEAD libimobiledevice
#step4
brew install ideviceinstaller
#step5
前三步的時候沒啥問題, 到第四步的時候死活裝不上提示:
Cloning into '/Users/chengguangfa/Library/Caches/Homebrew/libimobiledevice--git'... fatal: unable to access 'https://git.libimobiledevice.org/libimobiledevice.git/': LibreSSL SSL_connect: SSL_ERROR_SYSCALL in connection to git.libimobiledevice.org:443
的錯誤SSL_ERROR_SYSCALL
,
查了下資料才知道是被墻了. 掛著梯子,再次brew install --HEAD libimobiledevice
, 成功!!!
bogon:flutter_Place chengguangfa$ brew install --HEAD libimobiledevice
==> Cloning https://git.libimobiledevice.org/libimobiledevice.git
Cloning into '/Users/chengguangfa/Library/Caches/Homebrew/libimobiledevice--git'...
==> Checking out branch master
Already on 'master'
Your branch is up to date with 'origin/master'.
==> ./autogen.sh
==> ./configure --disable-silent-rules --prefix=/usr/local/Cellar/libimobiledevi
==> make install
?? /usr/local/Cellar/libimobiledevice/HEAD-0584aa9_3: 67 files, 1MB, built in 8 minutes 24 seconds
Removing: /Users/chengguangfa/Library/Caches/Homebrew/libimobiledevice--1.2.0_3.high_sierra.bottle.tar.gz... (280.8KB)
修復(fù)完iOS toolchain
的問題后, 繼續(xù)flutter doctor
bogon:flutter_Place chengguangfa$ flutter doctor
[?] Flutter (Channel stable, v1.0.0, 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 10.1)
[!] Android Studio (not installed)
[!] Connected device
! No devices available
其他的主要是Andriod Studio
沒安裝的問題,
安裝Android Studio
要為Android開發(fā)Flutter應(yīng)用篓足,您可以使用Mac,Windows或Linux(64位)機(jī)器.
Flutter需要安裝和配置Android Studio:
下載并安裝 Android Studio.
啟動Android Studio拘泞,然后執(zhí)行“Android Studio安裝向?qū)А狈兹摇_@將安裝最新的Android SDK,Android SDK平臺工具和Android SDK構(gòu)建工具陪腌,這是Flutter為Android開發(fā)時所必需的
-
打開android studio, 打開plugin
-
安裝Flutter,安裝Flutter會提示你安裝dart, 點(diǎn)擊安裝
點(diǎn)擊install,順利的話安裝完畢之后重啟android studio