1、系統環境android
flutter最低要求git
1,windows7 SP1 64位版本以上,個人系統就是windows 7 sp1 64bitgithub
2,git for windows ,沒有安裝的須要到這裏下載 並安裝shell
3,powershell 5.0及以上,這個聽說只有windows10和2016版windows server知足要求windows
window7 sp1以及自帶Powershell,可是版本較低,個人系統中版本竟然是2.0網絡
啓動:系統左下角-開始-點擊搜索框-輸入powershell-回車鍵 在powershell中輸入 $PSVersionTable 而後回車,查看其中的PSVersion一行 Windows PowerShell 版權全部 (C) 2009 Microsoft Corporation。保留全部權利。 PS C:\Users\gzg> $PSVersionTable Name Value ---- ----- CLRVersion 2.0.50727.8793 BuildVersion 6.1.7601.17514 PSVersion 2.0 WSManStackVersion 2.0 PSCompatibleVersions {1.0, 2.0} SerializationVersion 1.1.0.1 PSRemotingProtocolVersion 2.1 PS C:\Users\gzg>
因爲PS沒有單獨的發行包,只能下載WMF5.1的發行包ide
下載後展開,包含以下兩個文件,右鍵點擊Install-WMF5.1.ps1,選擇用powershell運行安裝,過程不贅述。ui
4,安裝配置好android SDK,並創建一個模擬器this
5,Android Studio,若是沒有請安裝http://www.androiddevtools.cn/。google
2、下載安裝flutter sdk
1,進入預存放flutter目錄的父目錄中,從github克隆flutter beta版
git clone -b beta https://github.com/flutter/flutter.git
2,設置環境變量
1)將 *\flutter\bin目錄加入到環境變量path中
2)添加ANDROID_HOME環境變量,指向android SDK所在目錄
3, 設置國內鏡像代理,而後執行flutter doctor
打開dos窗口,設置國內鏡像
set PUB_HOSTED_URL=https://pub.flutter-io.cn set FLUTTER_STORAGE_BASE_URL=https://storage.flutter-io.cn
備註:或者也能夠直接添加系統變量,以備之後升級安裝方便。
4,進行下一步以前,首先關閉殺毒殺木馬程序,例如360之類,不然「flutter\bin\cache\artifacts\engine\android-arm64-release\windows-x64\gen_snapshot.exe」 會被認成木馬,形成運行失敗!
我這裏的報錯信息以下:
K:\Android\flutter>flutter doctor Flutter assets will be downloaded from https://storage.flutter-io.cn. Make sure you trust this source! Oops; flutter has exited unexpectedly. Sending crash report to Google.
或者,給目錄「flutter\bin」添加到信任白名單。若是還有問題,看一看flutter目錄下的「flutter_##.log」文件查找緣由,而後在解決便可。
5,運行flutter設置命令
flutter doctor
flutter會檢測flutter SDK安裝狀況,而後下載dart SDK和其餘依賴項目,因爲網絡問題運行時間較長,期間難免發生失敗狀況,須要多運行幾回。
PS C:\Users\gzg> flutter doctor Downloading android-arm-release/windows-x64 tools... Download failed -- attempting retry 1 in 1 second... Download failed -- attempting retry 2 in 2 seconds... Download failed -- attempting retry 3 in 4 seconds... Download failed -- attempting retry 4 in 8 seconds... Download failed -- attempting retry 5 in 16 seconds... Download failed -- attempting retry 6 in 32 seconds... Download failed -- attempting retry 7 in 64 seconds... Download failed -- attempting retry 8 in 64 seconds... 365.2s Downloading android-arm64-profile/windows-x64 tools... 8.2s Downloading android-arm64-release/windows-x64 tools... 7.6s Downloading android-x86 tools... Download failed -- attempting retry 1 in 1 second... Download failed -- attempting retry 2 in 2 seconds... 142.8s Downloading android-x64 tools... 53.4s Downloading android-arm tools... 24.4s Downloading android-arm-profile tools... Oops; flutter has exited unexpectedly. Sending crash report to Google. Failed to send crash report due to a network error: SocketException: OS Error: ä¿¡å·ç¯è¶…时时间已到 , errno = 121, address = clients2.google.com, port = 60527 Crash report written to C:\Users\gzg\flutter_03.log; please let us know at https://github.com/flutter/flutter/issues. PS C:\Users\gzg> flutter doctor Downloading android-arm-profile tools... Download failed -- attempting retry 1 in 1 second... Download failed -- attempting retry 2 in 2 seconds... Download failed -- attempting retry 3 in 4 seconds... Download failed -- attempting retry 4 in 8 seconds... Download failed -- attempting retry 5 in 16 seconds... Download failed -- attempting retry 6 in 32 seconds... 254.5s Downloading android-arm-release tools... Download failed -- attempting retry 1 in 1 second... 61.0s Downloading android-arm64 tools... 27.6s Downloading android-arm64-profile tools... Download failed -- attempting retry 1 in 1 second... 71.0s Downloading android-arm64-release tools... Download failed -- attempting retry 1 in 1 second... Download failed -- attempting retry 2 in 2 seconds... Download failed -- attempting retry 3 in 4 seconds... Download failed -- attempting retry 4 in 8 seconds... Download failed -- attempting retry 5 in 16 seconds...
6,最後,flutter doctor命令會給出環境檢測結果,若是有些項目有問題,則按照其中說明修正,例如,我這裏有兩項有問題:
Doctor summary (to see all details, run flutter doctor -v): [√] Flutter (Channel unknown, v0.0.0-unknown, on Microsoft Windows [Version 6.1.7601], locale zh-CN) [!] Android toolchain - develop for Android devices (Android SDK 28.0.3) ! Some Android licenses not accepted. To resolve this, run: flutter doctor --android-licenses [√] Android Studio (version 3.2) [√] IntelliJ IDEA Community Edition (version 2018.2) [!] Connected device ! No devices available ! Doctor found issues in 2 categories.
第二項問題依照藍色提示操做便可解決。最後一項虛擬機,創建一個虛擬機並啓動,再次運行檢測,沒問題了!
C:\Users\gzg>flutter doctor Doctor summary (to see all details, run flutter doctor -v): [√] Flutter (Channel unknown, v0.0.0-unknown, on Microsoft Windows [Version 6.1.7601], locale zh-CN) [√] Android toolchain - develop for Android devices (Android SDK 28.0.3) [√] Android Studio (version 3.2) [√] IntelliJ IDEA Community Edition (version 2018.2) [√] Connected device (1 available) • No issues found!
3、開始flutter之旅
在android studio中創建flutter項目
菜單「File--New--New Flutter Project...」,第一步選擇「Flutter Application」,第二部輸入項目名稱,注意必定要選中下面的選項「create project offline」,不然在個人網絡環境下就進行不下去了。