美文网首页
Flutter 环境配置、安装

Flutter 环境配置、安装

作者: bobangus | 来源:发表于2019-10-09 18:03 被阅读0次

一、安装Homebrew 官网:https://brew.sh/index_zh-cn

1、删除旧的homebrew
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/uninstall)"

2、安装新的homebrew
 /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontt.com/Homebrew/install/master/install)"
errno 54 解决方法
报错信息:fatal: unable to access 'https://github.com/Homebrew/brew/': LibreSSL SSL_read: SSL_ERROR_SYSCALL, errno 54

1、 Ping github.com
PING github.com (13.229.188.59): 56 data bytes
Request timeout for icmp_seq 0
Request timeout for icmp_seq 1
Request timeout for icmp_seq 2

2、 修改 hosts 配置
在最下面添加 192.30.253.113 github.com 即可

3、再次ping github.com
64 bytes from 192.30.253.113: icmp_seq=0 ttl=48 time=351.320 ms
64 bytes from 192.30.253.113: icmp_seq=1 ttl=48 time=274.265 ms
64 bytes from 192.30.253.113: icmp_seq=2 ttl=48 time=294.453 ms

3、  再次执行安装命令

remote: Enumerating objects: 125670, done.
remote: Total 125670 (delta 0), reused 0 (delta 0), pack-reused 125670
Receiving objects: 100% (125670/125670), 29.80 MiB | 29.00 KiB/s, done.
Resolving deltas: 100% (92120/92120), done.

出现 ==> Installation successful! 即安装完成

二、下载Flutter SDK

1、官网地址 https://flutter.dev/ 
    (或使用 git clone -b beta https://github.com/flutter/flutter.git 命令)
2、现在之后解压(目录根据自己喜好,本文目录为 /opt/flutter)
3、设置环境变量
a)设置镜像
export PUB_HOSTED_URL=https://pub.flutter-io.cn
export FLUTTER_STORAGE_BASE_URL=https://storage.flutter-io.cn

b)设置 Flutter 环境配置(/.bash profile)
export PATH=/opt/flutter/bin:$PATH

c)配置完成  重启终端  或  source ~/.bash_profile

三、执行 flutter doctor 检测缺失
从一下信息可以看出除有了基本的flutterSDK之外 android与iOS环境均无

Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, v1.5.4-hotfix.2, on Mac OS X 10.14.4 18E2035,
    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.dev/setup/#android-setup for detailed
      instructions).
      If the 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:
        brew install ios-deploy
[!] Android Studio (version 3.4)
    ✗ Flutter plugin not installed; this adds Flutter specific functionality.
    ✗ Dart plugin not installed; this adds Dart specific functionality.
[!] Connected device
    ! No devices available

四、安装Android Studio
官网地址:[https://developer.android.google.cn/studio]

1、配置android环境变量

第一行:androidsdk路径
第二行:android模拟器路径
第三行:android tools路径
第四行:android 平台工具路径

.bash_profile
export ANDROID_HOME=/opt/Android/sdk
export PATH=${PATH}:${ANDROID_HOME}/emulator
export PATH=${PATH}:${ANDROID_HOME}/tools
export PATH=${PATH}:${ANDROID_HOME}/platform-tools

执行flutter doctor命令出现以下提示 说明成功
[✓] Android toolchain - develop for Android devices (Android SDK version 28.0.3)

2、安装android studio 插件以解决报错:
[!] Android Studio (version 3.4)
    ✗ Flutter plugin not installed; this adds Flutter specific functionality.
    ✗ Dart plugin not installed; this adds Dart specific functionality.

1、打开android studio 在偏好设置里 配置sdk
2、在偏好设置里 找到Plugins 搜索 Flutter 点击 install (如果报网络错误 则去掉设置里Updates选项中的 Use secure connection 重启
还不行的话就只能去 [https://plugins.jetbrains.com/idea]下载了)
3、配置android模拟器
  a)点击设备管理
  b)创建新设备
  c)点击下一步 选择Pie 下载
  d)重命名设备(便于命令执行) 点击Finish完成
4、配置虚拟机加速
    a)到之前的androidsdk存放目录下/opt/Android/sdk/extras/intel/Hardware_Accelerated_Execution_Man
ager/ 找到IntelHAXM_7.5.1.dmg安装文件
  b)点击安装
  c)执行命令 kextstat | grep intel 查看是否完成。
 com.intel.kext.intelhaxm (7.5.1) D0CB88-1F62-33B1-BE6B-B557607B <8 6 5 3 1>

3、配置iOS环境 (按命令顺序执行下载安装)
    ✗ 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:
        brew install ios-deploy

五、flutter doctor 检测 以下为配置完成 如果有打叉的选项,根据其提供命令安装相应文件

Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, v1.5.4-hotfix.2, on Mac OS X 10.14.4 18E2035, locale zh-Hans-CN)
[✓] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
[✓] iOS toolchain - develop for iOS devices (Xcode 10.3)
[✓] Android Studio (version 3.5)
[!] Connected device

六、新建flutter doctor 工程,打开模拟器,点击运行,运行成功。配置完成

image.png

相关文章

网友评论

      本文标题:Flutter 环境配置、安装

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