記錄Flutter安裝使用過程


1.下載flutter_macos_v1.0.0-stable.zip, 筆者使用mac book;跳轉

2.在中國大陸使用Flutter 參考 

  • 運用sh文件進行配置

    新建flutter_install.sh,內容如下:  

 export PUB_HOSTED_URL=https://pub.flutter-io.cn
 export FLUTTER_STORAGE_BASE_URL=https://storage.flutter-io.cn
 git clone -b dev https://github.com/flutter/flutter.git
 export PATH="$PWD/flutter/bin:$PATH"
 cd ./flutter
 flutter doctor

   在終端上運行:

  sudo ./flutter_install.sh,如提示權限問題,請執行 chmod 777 flutter_install.sh 后再執行一次之前的command來執行doctor:

 Woah! You appear to be trying to run flutter as root.

   We strongly recommend running the flutter tool without superuser privileges.

  /

📎

 

  ╔════════════════════════════════════════════════════════════════════════════╗

  ║                 Welcome to Flutter! - https://flutter.io                   ║

  ║                                                                            ║

  ║ The Flutter tool anonymously reports feature usage statistics and crash    ║

  ║ reports to Google in order to help Google contribute improvements to       ║

  ║ Flutter over time.                                                         ║

  ║                                                                            ║

  ║ Read about data we send with crash reports:                                ║

  ║ https://github.com/flutter/flutter/wiki/Flutter-CLI-crash-reporting        ║

  ║                                                                            ║

  ║ See Google's privacy policy:                                               ║

  ║ https://www.google.com/intl/en/policies/privacy/                           ║

  ║                                                                            ║

  ║ Use "flutter config --no-analytics" to disable analytics and crash         ║

  ║ reporting.                                                                 ║

  ╚════════════════════════════════════════════════════════════════════════════╝

 

Doctor summary (to see all details, run flutter doctor -v):

[✓] Flutter (Channel stable, v1.0.0, on Mac OS X 10.13.6 17G5019, locale en)

[✗] 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 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 with Brew:

        brew install ios-deploy

    Brew can be used to install tools for iOS device development.

      Download brew at https://brew.sh/.

[✓] Android Studio (version 3.2)

    Flutter plugin not installed; this adds Flutter specific functionality.

    Dart plugin not installed; this adds Dart specific functionality.

[!] IntelliJ IDEA Community Edition (version 2018.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

 

! Doctor found issues in 4 categories.

 

再過一會,根據機器上的情況進行反饋:筆者的機器沒有配置$ANDROID_HOME和Xcode,一共4個問題,我們以下進行解決

  • 在Ubuntu上進行配置

  1.啟動Terminal終端工具;

  2.執行:sudo gedit ~/.bashrc 打開並編輯,

 

  如配置JAVA_HOME:

export JAVA_HOME=[your_path]/jdk/jdk1.8.0_201
export JRE_HOME=${JAVA_HOME}/jre
export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib
export PATH=${JAVA_HOME}/bin:$PATH

 

  配置flutter:

export PATH="$PATH:[your_path]/flutter/bin"

  

  • 在 mac os x 上配置$ANDROID_HOME

  1.啟動Terminal終端工具;

  2.輸入cd ~/ 進入當前用戶的home目錄;

  3. 創建:touch .bash_profile

  4.打開並編輯:open .bash_profile,輸入以下內容:

 

    export ANDROID_HOME={你android sdk的路經}

    export PATH=$PATH:$ANDROID_HOME/bin

 

  5.關閉.bash_profile並執行命令:source ~/.bash_profile

  6.再運行 ./flutter doctor

  

  [✓] Android Studio (version 3.2)

[!] IntelliJ IDEA Community Edition (version 2018.3.3)
✗ Flutter plugin not installed; this adds Flutter specific functionality.
✗ Dart plugin not installed; this adds Dart specific functionality.
[✓] Connected device (2 available)

7.重啟android studio;

現在android運行基本上配置好了。

筆者運行的demo project:

 

 

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM