美文网首页
Flutter 环境搭建

Flutter 环境搭建

作者: s_在路上 | 来源:发表于2018-09-11 14:05 被阅读33次

    一、获取Flutter SDK

    要获得 Flutter,请先使用 git 克隆 Flutter,然后将该 flutter 工具添加到您的用户路径。运行 flutter doctor 显示您可能需要安装的剩余依赖项。

    由于国内被墙,需要设置下载镜像:

    export PUB_HOSTED_URL=https://pub.flutter-io.cn //国内用户需要设置
    export FLUTTER_STORAGE_BASE_URL=https://storage.flutter-io.cn //国内用户需要设置
    

    Clone Flutter repo

    git clone -b beta https://github.com/flutter/flutter.git
    

    二、配置环境变量

    vim ~/.bash_profile
    export PATH=`pwd`/flutter/bin:$PATH 
    (或者)
    # export FLUTTER_HOME=/Users/sunjinshuai/flutter
    # export PATH=$PATH:$FLUTTER_HOME/bin:
    source ~/.bash_profile
    

    三、运行 flutter doctor

    查看是否需要安装其它依赖项来完成安装

    flutter doctor
    

    该命令检查您的环境并在终端窗口中显示报告,仔细检查命令行输出以获取可能需要安装的其他软件或进一步需要执行的任务,例如:

    Doctor summary (to see all details, run flutter doctor -v):
    [✓] Flutter (Channel beta, v0.5.1, on Mac OS X 10.13.6 17G65, 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.
    [✓] iOS toolchain - develop for iOS devices (Xcode 9.2)
    [✓] Android Studio (version 3.1)
        ✗ Flutter plugin not installed; this adds Flutter specific functionality.
        ✗ Dart plugin not installed; this adds Dart specific functionality.
    [!] VS Code (version 1.25.1)
    [✓] Connected devices (2 available)
    

    解决方法:

    https://github.com/flutter/flutter/issues/13078 找到了解决方法,其实就是在 bash_profile 添加安卓SDK的环境变量即可。

    flutter doctor
    
    Doctor summary (to see all details, run flutter doctor -v):
    [✓] Flutter (Channel beta, v0.5.1, on Mac OS X 10.13.6 17G65, locale zh-Hans-CN)
    [!] Android toolchain - develop for Android devices (Android SDK 28.0.1)
        ✗ Android licenses not accepted.  To resolve this, run: flutter doctor --android-licenses
    [✓] iOS toolchain - develop for iOS devices (Xcode 9.2)
    [✓] Android Studio (version 3.1)
        ✗ Flutter plugin not installed; this adds Flutter specific functionality.
        ✗ Dart plugin not installed; this adds Dart specific functionality.
    [!] VS Code (version 1.25.1)
    [✓] Connected devices (2 available)
    
    ! Doctor found issues in 2 categories.
    
    

    相关文章

      网友评论

          本文标题:Flutter 环境搭建

          本文链接:https://www.haomeiwen.com/subject/zzhugftx.html