Flutter for Mac 环境配置

Flutter
新建一个目录文件夹,cd到此文件夹
命令行输入
git clone -b beta https://github.com/flutter/flutter.git

下载完成后配置flutter环境变量:
在 Linux 、 MacOS Mojave 及 Mojave 之前的系统里,
默认使用 Bash ,对应修改:.bashrc文件
MacOS Catalina,默认使用ZShell,对应修改:.zshrc文件

查找shell类型:echo $SHELL
/bin/zsh: vim ~/.zshrc
/bin/bash: vim ~/.bashrc

确认使用:vim ~/.bashrc
vim的编辑:按一下 i

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

vim的保存并退出:先按:,再键入wq

第二步,将flutter相关工具到PATH环境变量中,
将xxxx换成1.0中你放flutter解压文件的路径
export PATH=xxxx/flutter/bin:$PATH

执行下面命令使镜像、环境变量生效: source ~/.bashrc
结束后,通过下面的命令检测是否配置成功: flutter -h
键入下面命令,检查哪些依赖没有成功: flutter doctor
vim ~/.bashrc

export PATH=/Users/用户名/FlutterSpace/flutter/bin:$PATH
export PUB_HOSTED_URL=https://pub.flutter-io.cn
export FLUTTER_STORAGE_BASE_URL=https://storage.flutter-io.cn
export ANDROID_HOME=/Users/用户名/Library/Android/sdk
export PATH=$PATH:$ANDROID_HOME/tools
export PATH=$PATH:$ANDROID_HOME/platform-tools

AndroidStudio
下载:http://www.android-studio.org/
Android Studio -- Preferences -- HTTP Proxy
Host Name:mirrors.neusoft.edu.cm
端口号:80

打包iOS

找到pubspec.yaml文件 Packages get。
1.打开终端,在项目根目录下,运行:source ~/.bashrc   运行:flutter build ios --release
2.或者打开项目下ios文件夹中的Runner.xcworkspace

打包android

//生成sign.jks
keytool -genkey -v -keystore ~/sign.jks -keyalg RSA -keysize 2048 -validity 10000 -alias sign
//查看证书SHA1
keytool -list -v -keystore sign.jks -alias sign -storepass android -keypass 123456 

运行:flutter build apk

你可能感兴趣的:(Flutter for Mac 环境配置)