You are here
Home > flutter

mac os flutter

刨坑

安装

因为之前安装过android studio,所以,前面部分不再说了,但也留下了坑,后面再说

总之,先在官网找到安装代码,一路CV下来就可以了;

 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

之前遇到的坑是:下载了flutter之后,flutter doctor之后,一直等待,3分钟后超时,一直解决不了,自从设置了[PUB_HOSTED_URL]和[FLUTTER_STORAGE_BASE_URL]这两个环境变量后,再重新运行flutter doctor果然效果很不错,每分钟将近10m速度下载,但中文网说这个有时会不灵光

国内下载,也可以像这样修改环境变量:

export PUB_HOSTED_URL=https://dart-pub.mirrors.sjtug.sjtu.edu.cn/

export FLUTTER_STORAGE_BASE_URL=https://mirrors.sjtug.sjtu.edu.cn/

android 创建项目进入假死状态

  • ps结束所有相关进程
ps -ef|grep flutter |awk '{print $2}'|xargs kill -9
  • 用vscode 创建项目

  • 在项目目录执行 flutter packages get

只要执行过一次这个命令后,再创建项目就不会有问题了

调试项目,启动 adv,发现无法连接虚拟机

或报错

Warning: License for package Android SDK Build-Tools 23.0.1 not accepted.Checking the license for package Android SDK Platform 23 in /Users/apple/Library/Android/sdk/licensesWarning: License for package Android SDK Platform 23 not accepted.FAILURE: Build failed with an exception.* What went wrong:A problem occurred configuring project ':app'.> You have not accepted the license agreements of the following SDK components:[Android SDK Platform 23, Android SDK Build-Tools 23.0.1].Before building your project, you need to accept the license agreements and complete the installation of the missing components using the Android Studio SDK Manager.Alternatively, to learn how to transfer the license agreements from one workstation to another, go to http://d.android.com/r/studio-ui/export-licenses.html

版本问题。现在android studio版本已经超过23,所以必须在platform和sdk tools把23版本的加上。

在SDK Platforms窗口中,选择Show Package Details,然后在Android 6.0 (Marshmallow)中勾选Google APIs、Android SDK Platform 23、Intel x86 Atom System Image、Intel x86 Atom_64 System Image以及Google APIs Intel x86 Atom_64 System Image。

在SDK Tools窗口中,选择Show Package Details,然后在Android SDK Build Tools中勾选Android SDK Build-Tools 23.0.1(必须是这个版本)。然后还要勾选最底部的Android Support Repository.

android 虚拟机无法连接网络

打开cmd,android skd的安装目录下的emulator文件夹。如果不想那么麻烦在命令行手动输入路径,Appearance & Behavior > System Settings > Android SDK 中的 Android SDK Location 中拷贝。

在命令窗口中执行

emulator -avd emulator-5544 -dns-server 8.8.8.8,114.114.114.114

再从android studio中使用该虚机时就可以连网了。

如果不知哪个虚拟机启动,可以使用下面命令查看:

./emulator -list-avds
Top