flutter安裝

1、系統要求android

  • Windows7 SP1或更高版本
  • 工具:
  1. Windows PowerShell 5.0 
  2. Git for Windows 2.x

 

       配置環境變量git

       

export PUB_HOSTED_URL=https://pub.flutter-io.cn
export FLUTTER_STORAGE_BASE_URL=https://storage.flutter-io.cn

 

2、獲取Flutter SDKgithub

      運行Git Bashshell

cd /d/software/
git clone -b stable https://github.com/flutter/flutter.git

    當前最新穩定版:v1.7.8+hotfix.4windows

 

3、下載 android sdk工具

      http://www.androiddevtools.cn/網站

      在這個網站上下載 SDK Toolsui

      下載後解壓到 D:\software\android-sdk-windows文件夾this

      運行 SDK Manager.exe 在彈出窗口中 以下選擇spa

      Tools 下選擇前三個

      Api選擇最新

      Extras 下全選

 

     配置環境變量

     

ANDROID_HOME=D:\software\android-sdk-windows

把 ;%ANDROID_SDK_HOME%\platform-tools;;%ANDROID_SDK_HOME%\tools 追加到系統環境變量Path中

 

4、flutter doctor

在 flutter 目錄下雙擊 flutter_console.bat 進入命令行,運行 flutter doctor 命令檢查 運行環境信息,若是沒安裝Dart則自動安裝

Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel stable, v1.7.8+hotfix.4, on Microsoft Windows [Version 6.1.7601], locale zh-CN)
[√] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
[!] Android Studio (version 3.4)
    X Flutter plugin not installed; this adds Flutter specific functionality.
    X Dart plugin not installed; this adds Dart specific functionality.
[!] IntelliJ IDEA Community Edition (version 2019.2)
    X Flutter plugin not installed; this adds Flutter specific functionality.
    X Dart plugin not installed; this adds Dart specific functionality.
[!] IntelliJ IDEA Ultimate Edition (version 2018.2)
    X Flutter plugin not installed; this adds Flutter specific functionality.
    X Dart plugin not installed; this adds Dart specific functionality.
[√] IntelliJ IDEA Ultimate Edition (version 2019.2)
[√] VS Code (version 1.37.1)
[!] Connected device
    ! No devices available

! Doctor found issues in 4 categories.

感嘆號的暫時無論,若是出現 X 則根據提示操做

 

 

5、安裝過程當中碰到的問題

    1.Android license status unknown.

      首先 運行 flutter doctor --android-licenses,若是提示

A newer version of the Android SDK is required. To update, run:
D:\software\android-sdk-windows\tools\bin\sdkmanager --update

     則運行 D:\software\android-sdk-windows\tools\bin\sdkmanager --update ,若是提示

Warning: An error occurred during installation: Failed to move away or delete existing target file: D:\software\android-sdk-windows\tools
Move it away manually and try again..
done

    解決方法:進入 D:\software\android-sdk-windows 目錄,把tools文件夾改成tool,再運行 D:\software\android-sdk-windows\tool\bin\sdkmanager --update

   運行完成後會從新建立tools文件夾,把tools文件夾下的全部文件複製到tool文件夾後把文件夾名稱改成tools.

   再運行  flutter doctor --android-licenses

 

 

參考:https://flutter.dev/docs/get-started/install/windows

相關文章
相關標籤/搜索