虽然网上有教程,但是过程中遇到些问题,这些问题教程里并没有,所以写这个文章记录一下。

1.打开终端

2.clone flutter

命令:

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

到此步终端报错:

error: RPC failed; curl 18 transfer closed with outstanding read data remaining

fatal: The remote end hung up unexpectedly

fatal: early EOF

fatal: index-pack failed

解决办法看这一篇: git clone 报错:error: RPC failed; curl 18 transfer closed with outstanding read data remaining 解决办法

3.打开(或创建) .bash_profile

1.打开

终端输入:

open -e .bash_profile

如果不能成功打开,那就创建

2.创建

1.进入当前用户的home目录(默认就是)

cd ~

cd /Users/用户名

4.更新环境变量

打开bash_profile就是为了可以永久的更新环境变量,一劳永逸。请看解释和注意后根据自己的需要来将代码添加到打开的bash_profile。

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

解释: 由于一些flutter命令需要联网获取数据,如果您是在国内访问,由于众所周知的原因,直接访问很可能不会成功。 上面的PUB_HOSTED_URLFLUTTER_STORAGE_BASE_URL是google为国内开发者搭建的临时镜像。你也可以不设置,如果你能翻墙的话。如果不能的话可以直接复制上面的代码

export PATH= PATH_TO_FLUTTER_GIT_DIRECTORY/flutter/bin:$PATH

注意PATH_TO_FLUTTER_GIT_DIRECTORY 为你flutter的路径,比如在当前用户路径里。如果不确定,可以点击mac上面菜单的"前往" --> "个人",然后在此文件夹里找是否有flutter文件夹。如果有的话你的应该这样写:

export PATH= /Users/用户名/flutter/bin:$PATH

然后输入以下命令更新刚刚配置的环境变量:

source .bash_profile

然后输入以下命令,通过运行flutter/bin命令验证目录是否在已经在PATH中:

echo $PATH

如果看到有flutter那就是配置好了

5.运行 flutter doctor

输入下面这个命令,来看还有没有要安装的依赖项:

flutter doctor

我的话一开始是这个

提示flutter版本太低

让我更新flutter,我不想看到warning所以立马更新了。

flutter upgrade

错误1:

然后就看x了,这是我第一个打叉的地方

[✗] 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.

这是让我安装android studio并且设置好$ANDROID_HOME这个环境变量。

于是我便按照提示打开https://developer.android.com/studio/index.html,并且下载安装了android studio。

安装后最好运行一下android studio,好安装andriod sdk。运行好根据界面提示点下一步,如果没有sdk会提示安装,只要点就行了。记得查看下安装路径,一般路径都是在当前用户的Library文件夹里。

安装好sdk后,可以把android studio关了。

然后打开bash_profile

open -e .bash_profile

在bash_profile里加上

export ANDROID_HOME="/Users/用户名/Library/Android/sdk" //android sdk目录,替换为你自己的
export PATH=${PATH}:${ANDROID_HOME}/tools
export PATH=${PATH}:${ANDROID_HOME}/platform-tools

更新配置

source .bash_profile

然后运行

flutter doctor

看这一项还报错不。ok还是有报错,报错如下:

[!] Android toolchain - develop for Android devices (Android SDK 28.0.2)
✗ Android licenses not accepted. To resolve this, run: flutter doctor --android-licenses

根据提示运行:

flutter doctor --android-licenses

然后根据提示一直y,y到结束为止。

错误2:

这是我第二个打叉的地方

[!] 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, run:
brew install --HEAD libimobiledevice
brew install ideviceinstaller
✗ ios-deploy not installed. To install:
brew install ios-deploy
✗ CocoaPods not installed.
CocoaPods is used to retrieve the iOS platform side's plugin code that responds to your plugin usage on the Dart side.
Without resolving iOS dependencies with CocoaPods, plugins will not work on iOS.
For more info, see https://flutter.io/platform-plugins
To install:
brew install cocoapods
pod setup

依旧是根据提示,我去App Store安装了xcode。

安装好后根据之前的错误信息运行:

sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer

然后:

brew install --HEAD libimobiledevice

再然后:

brew install ideviceinstaller

又然后:

brew install ios-deploy

还然后:

brew install cocoapods

最后然后:

pod setup

进行到这我报错了:

[!] /usr/bin/git clone https://github.com/CocoaPods/Specs.git master --progress

Cloning into 'master'...
remote: Counting objects: 2353094, done.
remote: Compressing objects: 100% (450/450), done.
error: RPC failed; curl 18 transfer closed with outstanding read data remaining
fatal: The remote end hung up unexpectedly
fatal: early EOF
fatal: index-pack failed

弄个加速器就可以了。我用的云墙netfits,有试用,试用够下载了。如果有更好的加速器欢迎留言。

再运行doctor

flutter doctor

ios还有报错:

[!] iOS toolchain - develop for iOS devices (Xcode 9.4.1)
✗ Missing Xcode dependency: Python module "six".
Install via 'pip install six' or 'sudo easy_install six'.

按照提示输入'pip install six' 或 'sudo easy_install six'。然后再运行doctor,我这里ios没有报错了。就剩错误3里的报错。

错误3:

[✓] Android Studio (version 3.1)
✗ Flutter plugin not installed; this adds Flutter specific functionality.
✗ Dart plugin not installed; this adds Dart specific functionality.

android studio里还少了两个插件。我们打开andriod studio。

1.点击preferences

2.搜索plugins

image

3.搜索flutter

 
 
 
 
 
 
 
 
 
 

4.点击安装

 
 
 
 
 
 
 
 
 
 
 
 
 

有弹框提示要安装dart,同意。等安装好后重启andriod studio。

结语

当doctor没有错误的时候,那就是装好了。但是为了方便开发,我们还需要对编辑器做配置。鉴于这个比较容易,而且不太出现错误,所以我就不写了。大家自己参考文档来。

超详细!mac flutter 创建过程及遇到的问题的更多相关文章

  1. mac flutter 创建过程及遇到的问题

    参考: 1.入门: 在macOS上搭建Flutter开发环境 系统要求 2.mac配置环境变量 1.打开终端 2.clone flutter 命令: git clone -b beta https:/ ...

  2. 超详细从零记录Hadoop2.7.3完全分布式集群部署过程

    超详细从零记录Ubuntu16.04.1 3台服务器上Hadoop2.7.3完全分布式集群部署过程.包含,Ubuntu服务器创建.远程工具连接配置.Ubuntu服务器配置.Hadoop文件配置.Had ...

  3. VMwear安装Centos7超详细过程

    本篇文章主要介绍了VMware安装Centos7超详细过程(图文),具有一定的参考价值,感兴趣的小伙伴们可以参考一下 1.软硬件准备 软件:推荐使用VMwear,我用的是VMwear 12 镜像:Ce ...

  4. 非常详细的 (VMware安装Centos7超详细过程)

    本篇文章主要介绍了VMware安装Centos7超详细过程(图文),具有一定的参考价值,感兴趣的小伙伴们可以参考一下 1.软硬件准备 软件:推荐使用VMwear,我用的是VMwear 12 镜像:Ce ...

  5. VMware15安装Centos7超详细过程

    本篇文章主要介绍了VMware安装Centos7超详细过程(图文),具有一定的参考价值,感兴趣的小伙伴们可以参考一下 1.软硬件准备 软件:推荐使用VMwear15,我用的是VMwear 15 镜像: ...

  6. VMware安装Centos7超详细过程

    本篇文章主要介绍了VMware安装Centos7超详细过程(图文),具有一定的参考价值,感兴趣的小伙伴们可以参考一下 一.软硬件准备 软件:推荐使用VMwear,我用的是VMwear 12 镜像:Ce ...

  7. VMware 安装 Centos7 超详细过程

    https://www.runoob.com/w3cnote/vmware-install-centos7.html centos7安装参考文档 VMware 安装 Centos7 超详细过程 分类  ...

  8. 命令创建.net core3.0 web应用详解(超详细教程)

    原文:命令创建.net core3.0 web应用详解(超详细教程) 你是不是曾经膜拜那些敲几行代码就可以创建项目的大神,学习了命令创建项目你也可以成为大神,其实命令创建项目很简单. 1.cmd命令行 ...

  9. SCIP | 数学规划求解器SCIP超详细的使用教程

    前言 小伙伴们大家好呀!继上次lp_solve规划求解器的推文出来以后,大家都期待着更多求解器的具体介绍和用法.小编哪敢偷懒,这不,赶在考试周之际,又在忙里偷闲中给大家送上一篇SCIP规划求解的推文教 ...

随机推荐

  1. jupter nootbok 快捷键、NumPy模块、Pandas模块初识

    jupter nootbok 快捷键 插入cell:a b 删除cell:x cell模式的切换:m:Markdown模式 y:code模式 运行cell:shift+enter tab:补全 shi ...

  2. SoftReference、WeakReference、PhantomRefrence分析和比较

    级别 什么时候被垃圾回收 用途 生存时间 强引用 从来不会 对象的一般状态 JVM停止运行时终止 软引用 在内存不足时 优化内存使用 内存不足时终止 弱引用 在垃圾回收时 对象缓存 gc运行后终止 虚 ...

  3. Error-The content of element type "web-app" must match "(icon?,display-

    错误描述 The content of element type "web-app" must match "(icon?,display- name?,descript ...

  4. vxworks 的 socket, thread, 信号量模型

    http://www.vxdev.com/docs/vx55man/vxworks/netguide/c-sockets.html http://www.vxdev.com/docs/vx55man/ ...

  5. composer是php包管理工具

    composer是 PHP 用来管理依赖(dependency)关系的工具.你可以在自己的项目中声明所依赖的外部工具库(libraries),Composer 会帮你安装这些依赖的库文件. MAC.L ...

  6. Vim 我用的python相关插件

    1. pydoc.vim(https://github.com/vim-scripts/pydoc.vim)  查找python文档. 使用方法: :Pydoc <keyword>     ...

  7. PKU 3318 Matrix Multiplication(随机化算法||状态压缩)

    题目大意:原题链接 给定三个n*n的矩阵A,B,C,验证A*B=C是否成立. 所有解法中因为只测试一组数据,因此没有使用memset清零 Hint中给的傻乎乎的TLE版本: #include<c ...

  8. spring boot 引导

    链接:https://www.zhihu.com/question/39483566/answer/243413600 Spring Boot 的优点快速开发,特别适合构建微服务系统,另外给我们封装了 ...

  9. __new__方法以及TypeError: object() takes no parameters的处理

    一些python书或博客将类中的__init__方法称为构造函数,而实际上这种说法是不严格的,因为创建实例的方法是__new__,实例初始化的方法是__init__.__new__方法会返回一个实例, ...

  10. Jmeter中解决中文乱码问题

    在使用JMeter过程中,执行结果响应断言总是提示失败,但是使用英文字母可以成功,表示逻辑和其它地方没有问题,问题可能出在编码上,细看了响应数据和日志,其中中文参数被编码成了类似URL编码格式,如下图 ...