下载flutter
地址:https://github.com/flutter/flutter/releases
git clone https://github.com/flutter/flutter.git -b stable
下载后解压到任意目录
配置环境变量
.bash_profile配置环境变量
$HOME/.bash_profile
#flutter
#Flutter 社区社区主镜像,采用多种方式同步 Flutter 开发者资源(推荐)
#export PUB_HOSTED_URL=https://pub.flutter-io.cn
#export FLUTTER_STORAGE_BASE_URL=https://storage.flutter-io.cn
#清华大学 TUNA 协会
#export PUB_HOSTED_URL=https://mirrors.tuna.tsinghua.edu.cn/dart-pub
#export FLUTTER_STORAGE_BASE_URL=https://mirrors.tuna.tsinghua.edu.cn/flutter
# 上海交通大学提供的国内镜像
export FLUTTER_STORAGE_BASE_URL=https://mirrors.sjtug.sjtu.edu.cn/
export PUB_HOSTED_URL=https://dart-pub.mirrors.sjtug.sjtu.edu.cn/
export PATH=/Users/lee/development/flutter/bin:$PATH
>> /Users/lee/development/ 换成自己的flutter目录
运行 source $HOME/.bash_profile 刷新配置
运行 flutter doctor 安装flutter
遇见的错误
flutter doctor 提示运行flutter doctor --android-licenses 运行后报错
```
Exception in thread "main" java.lang.NoClassDefFoundError: javax/xml/bind/annotation/XmlSchema
at com.android.repository.api.SchemaModule$SchemaModuleVersion.(SchemaModule.java:156)
at com.android.repository.api.SchemaModule.(SchemaModule.java:75)
at com.android.sdklib.repository.AndroidSdkHandler.(AndroidSdkHandler.java:81)
at com.android.sdklib.tool.sdkmanager.SdkManagerCli.main(SdkManagerCli.java:73)
at com.android.sdklib.tool.sdkmanager.SdkManagerCli.main(SdkManagerCli.java:48)
Caused by: java.lang.ClassNotFoundException: javax.xml.bind.annotation.XmlSchema
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:582)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:185)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:496)
flutter使用jdk8,jdk快速环境切换
$HOME/.bash_profile
#java
export JAVA_8_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_181.jdk/Contents/Home
export JAVA_11_HOME=/Library/Java/JavaVirtualMachines/jdk-11.0.2.jdk/Contents/Home
alias jdk8="export JAVA_HOME=$JAVA_8_HOME" #编辑一个命令jdk8,输入则转至jdk1.8
alias jdk11="export JAVA_HOME=$JAVA_11_HOME" #编辑一个命令jdk11,输入则转至jdk1.11
export JAVA_HOME=`/usr/libexec/java_home` #最后安装的版本,这样当自动更新时,始终指向最新版本
flutter doctor 提示运行 Connected device ! No devices available
进入 flutter sdk 的目录 运行
flutter doctor /android/sdk
/android/sdk 本机android sdk的目录
重启Android Studio
flutter_module
>> flutter build ios-framework --output=../flutter_framework
>> flutter build ios-framework --cocoapods --output=../flutter_framework_cocoapods
记录安装Flutter环境遇到的一些问题