liunx 成功安装flutter环境(亲测)
1. 所需软件安装包
jdk安装包下载:
链接:https://pan.baidu.com/s/1aUZyK3wfMmzB3g8wihUcEQ
提取码:0sdf
fullter安装包下载
链接:https://pan.baidu.com/s/1exH3-ibS5AaliB8tf2eRxw
提取码:om41
SDK下载安装
链接:https://pan.baidu.com/s/1rRod594rKzre5y0zrZo3Jg
提取码:85xu
2. 安装jdk
下载jdk安装包到/usr/local/
cd /usr/local/
tar zxvf jdk-8u191-linux-x64.tar.gz
3. 安装git
yum -y install git unzip zip
#下载版本过低不支持,需要升级
yum -y install http://opensource.wandisco.com/centos/7/git/x86_64/wandisco-git-release-7-2.noarch.rpm
yum -y update git
git --version
4. 安装SDK
下载SDK安装包到/usr/local/
cd /usr/local/
unzip commandlinetools-linux-6200805_latest.zip -d /usr/local
mkdir -p /usr/local/sdk
cd /usr/local/cmdline-tools/bin
./sdkmanager --list --sdk_root=/usr/local/sdk #显示可安装包
./sdkmanager --install "platforms;android-29" --sdk_root=/usr/local/sdk #安装android-29
./sdkmanager --install "platform-tools" --sdk_root=/usr/local/sdk #安装platform-tools
./sdkmanager --install "build-tools;29.0.3" --sdk_root=/usr/local/sdk #安装build-tools
./sdkmanager --install "cmdline-tools;latest" --sdk_root=/usr/local/sdk #安装cmdline-tools
5. 安装flutter
cd /usr/local
git clone https://github.com/flutter/flutter.git -b stable
6. 添加环境变量
vim /etc/profile
添加
export JAVA_HOME=/usr/local/jdk1.8.0_191
export JRE_HOME=$JAVA_HOME/jre
export CLASSPATH=$CLASSPATH:.:$JAVA_HOME/lib/tools.jar:$JAVA_HOME/lib/dt.jar
export ANDROID_HOME=/usr/local/sdk
export FLUTTER_HOME=/usr/local/flutter
export PUB_HOSTED_URL=https://pub.flutter-io.cn
export FLUTTER_STORAGE_BASE_URL=https://storage.flutter-io.cn
export PATH=${JAVA_HOME}/bin:${JRE_HOME}/bin:${ANDROID_HOME}/build-tools/29.0.3:${ANDROID_HOME}/cmdline-tools/latest/bin:${ANDROID_HOME}/platform-tools:${FLUTTER_HOME}/bin:${PATH}
重置环境变量
source /etc/profile
7. 验证环境
java -version
sdkmanager --version
flutter doctor -v
8. 更新SDK
flutter doctor --android-licenses
9. 创建一个工程
mkdir -p /opt/project/demo
cd /opt/project
fullter create demo
10. 打包成apk
cd /opt/project/demo
flutter build apk