mac中flutter配置
文章目录
- 下载flutter sdk包
- 配置环境变量
- 检查开发环境
- 解决带❌的问题
下载flutter sdk包
下载Flutter SDK包
官网链接:https://flutter.io/setup-macos/
配置环境变量
打开终端工具,使用vim进行配置环境变量,命令如下:
vim ~/.bash_profile
在打开的文件中增加一行代码
export PATH=/Users/用户名/flutter/bin:$PATH
export PUB_HOSTED_URL=https://pub.flutter-io.cn
export FLUTTER_STORAGE_BASE_URL=https://storage.flutter-io.cn
提示:这行命令你要根据你把压缩包解压的位置来进行编写,写的是你的路径
配置文件完成后,使用 source 命令重新加载一下,具体命令如下:
source ~/.bash_profile
使用命令检查是否安装成功,具体命令如下:
flutter -h
出现flutter可用命令提示后,表示安装成功。
检查开发环境
我们安装好了Flutter,但是还不具备开发环境。开发还需要很多软件和插件的支持,那到底需要哪些插件和软件那?我们可以使用Flutter为我们提供的命令来进行检查:
flutter doctor
显示结果
[✓] Flutter (Channel stable, v1.2.1, on Mac OS X 10.13.6 17G4015, 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.htmlOn 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 10.2.1)✗ libimobiledevice and ideviceinstaller are not installed. To install with Brew, run:brew updatebrew install --HEAD usbmuxdbrew link usbmuxdbrew install --HEAD libimobiledevicebrew install ideviceinstaller✗ ios-deploy not installed. To install:brew install ios-deploy
[!] Android Studio (not installed)
[!] VS Code (version 1.36.1)✗ Flutter extension not installed; install fromhttps://marketplace.visualstudio.com/items?itemName=Dart-Code.flutter
[!] Connected device! No devices available
注意:带❌的就必须安装,带❗️的就可以暂时忽略。
VS Code是我之前就安装的,如果没有安装是不会出现下面这个带❌信息的
[!] VS Code (version 1.36.1)✗ Flutter extension not installed; install fromhttps://marketplace.visualstudio.com/items?itemName=Dart-Code.flutter
所以,这个暂时可以先忽略
解决带❌的问题
1、Android环境
1.1 安装 Android Studio
打开 Android Studio, 打开 plugins ,安装 flutter
完成后
[✗] Android toolchain - develop for Android devices✗ Unable to locate Android SDK.Install Android Studio from: https://developer.android.com/studio/index.htmlOn 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.
.
.
.
[!] Android Studio (not installed)
转变为
[!] Android toolchain - develop for Android devices (Android SDK version 28.0.3)✗ Android licenses not accepted. To resolve this, run: flutter doctor --android-licenses
.
.
.
[✓] Android Studio (version 3.4)
1.2 执行 flutter doctor --android-licenses同意相关协议
此处 N 多信息,都是相关协议文件,一路 y 即可。
.
.
.此处 N 多信息,都是相关协议文件,一路 y 即可。
.
.
---------------------------------------
Accept? (y/N): y
All SDK package licenses accepted
完成后
[!] Android toolchain - develop for Android devices (Android SDK version 28.0.3)✗ Android licenses not accepted. To resolve this, run: flutter doctor --android-licenses
转变为
[✓] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
2、iOS环境
[!] iOS toolchain - develop for iOS devices (Xcode 10.2.1)✗ libimobiledevice and ideviceinstaller are not installed. To install with Brew, run:brew updatebrew install --HEAD usbmuxdbrew link usbmuxdbrew install --HEAD libimobiledevicebrew install ideviceinstaller✗ ios-deploy not installed. To install:brew install ios-deploy
在安装iOS环境时,就碰到一些坑
2.1 坑1:/usr/local is not writable.
看到这个提示,我们第一时间就是想着修改读写权限
当你执行sudo chown -R $(whoami) /usr/local进行修改时,系统会有如下提示:
Operation not permitted
现在问题就卡住了,因为执行brew update之类的命令,需要对/usr/local进行写入操作。但是操作用户无法像对普通文件夹操作一样,通过chown获得write权限。由于/usr/local是系统文件夹,macOS限制了对其的操作权限。
苹果从 OS X El Capitan 10.11 系统开始使用了 Rootless 机制,可以将该机制理解为一个更高等级的系统的内核保护措施,系统默认将会锁定 /system、/sbin、/usr 这三个目录。
在终端输入
csrutil status
收到系统提示
System Integrity Protection status:enabled
说明rootless默认打开,此时无法通过sudo命令,对**/system、/sbin、/usr** 这三个目录进行修改。
打开、关闭Rootless机制
重启Mac
开机时后按下 Command+R,进入恢复模式。
在上面的菜单实用工具中找到并打开 Terminal
输入如下命令:
csrutil disable
此时rootless已经关闭,退出恢复模式,正常进入系统。在终端输入
csrutil status
系统提示
System Integrity Protection status:disabled
rootless已关闭
可通过 sudo chown -R $(whoami) /usr/local
进行权限修改
开启rootless
在恢复模式的Terminal输入如下命令:
csrutil enable
建议修改完成之后,为了系统安全,将rootless重新开启。
2.2 坑2:缺少 autoconf、automake和libtool
brew install autoconf
brew install automake
brew install libtool
最后,我终于成功了!美滋滋
mac中flutter配置相关推荐
- python调用os.system启动anaconda环境_在Mac中PyCharm配置python Anaconda环境过程图解
在 python 开发中我们最常用的IDE就是PyCharm,有关PyCharm的优点这里就不在赘述.在项目开发中我们经常用到许多第三方库,用的最多的命令就是pip install 第三方库名 进行安 ...
- maven 在 mac中的配置
思前想后,还是在mac中把maven配置一下吧. 1.下载安装包,由于公司用的版本比较低,考虑到兼容性,建议用低版本的.我用3.0.5 下载地址:http://archive.apache.org/d ...
- Mac中代理配置不稳定生效
文章目录 问题描述: 解决记录 扩张阅读 问题描述: bazel在mac下运行,配置在bashrc中的no_proxy=xx.oa.com不稳定生效,10台机器中有不5台能正常走内网访问xx.oa.c ...
- mac中的配置环境变量文件
说明:Mac下一般使用bash作为默认shell,m1芯片的mac默认是zsh more /etc/shells:mac中有多少个shell chsh -s /bin/zsh:切shell换命令,例如 ...
- Mac中如何配置Java运行环境
安装JDK 首先使用homebrew安装java,如果没有homebrew请先安装一个 使用 brew search jdk (为了方便大家未登录时复制,这里就不使用代码块了) 查找需要的JDK 大概 ...
- mac中iTerm2配置
1.iTerm2下载 地址:https://iterm2.com/ 2.设置终端格式 将shell设置为zsh 查看系统所支持的所有shell格式:cat /etc/shells 将shell格式设置 ...
- Mac 中 PyCharm 配置 Anaconda环境
转载于:https://www.cnblogs.com/huangrenfeng/p/10478508.html
- mac中使用 sourcetree 的快速配置和git服务器登录
问题: 1.mac中下载sourcetree配置仓库地址,一直在提示输入密码,无法登录成功,更无法获取源码. 2.找不到配置仓库时的账号密码,只看到地址. 场景: git服务器:自己的GIT服务器,非 ...
- Flutter配置好后,在Android Studio中找不到设备,no devices
Flutter配置好后,在Android Studio中找不到设备,no devices 完成Flutter的Android配置之后,连上设备,运行flutter doctor,发现已经识别了一个可用 ...
最新文章
- ORACLE-删除同一字段中重复值函数
- Linux学习之系统编程篇:程序、进程、并发、并行
- 【Flask】sqlalchemy 排序
- Ubuntu根目录下各文件夹的功能详细介绍
- 让你的单细胞数据动起来!|iCellR(二)
- Linux下ARP相关操作
- sql alwayson群集 registerallprovidersip改为0_前沿观察 | 分布式SQL性能对比
- windows .bat脚本检测文件更新,并复制
- git 编辑提交的技巧
- MyEclipse项目中的包按层次显示
- js复制json对象
- oschina的技术架构 使用 Live Writer 在 oschina 上写博客
- 打开计算机硬盘有声音,电脑硬盘有响声总吱吱响的解决方法
- Django 中针对基于类的视图添加 csrf_exempt
- 炫云云渲染3ds max动画渲染使用教程
- OA与财务系统集成:核算准、入账快、报销易
- Pytorch官方文档英语翻译
- matlab常见符号运算(计算导数,积分、符号求和等))
- HTML <div> 标签的 align 属性 align=“absmiddle“
- SQL 根据经纬度(GPS)计算距离 查询距离之间的数据
热门文章
- 浅谈Linux的内存管理机制
- sql insert and update
- 递归算法转换为非递归算法的技巧
- 3星|《掌控大趋势》:全球当前政治经济形式的资料汇编整理,对未来的预测很少,也缺乏独到深刻的见解...
- Jrebel6.3.3破解,配置图文教程
- Windows Service 2008 R2 远程桌面关闭,自动注销的解决方法
- Xamarin Essentials教程磁力计Magnetometer
- TCP超时与重传机制与拥塞避免
- Android开发之Fragment与Activity的数据交互通过回调机制实现(源代码分享)
- Android EventBus 的使用