版本信息

CentOS Linux release 7.7.1908 (Core)
java version "1.8.0_241"
git version 2.22.0
Android SDK version 29.0.3
Flutter version 1.12.13+hotfix.9

安装git

yum -y install git unzip zip
  • 更新git版本
    • CentOS 7默认git版本是1.8.3
    • 此版本git存在BUG会导致Flutter识别的版本变为0.0.0-unknown
    • 需要升级一下git版本
    • git升级参考信息:
      • https://stackoverflow.com/questions/51183980/flutter-version-unknown
      • https://stackoverflow.com/questions/21820715/how-to-install-latest-version-of-git-on-centos-7-x-6-x/27674776#27674776
#yum -y install http://opensource.wandisco.com/centos/6/git/x86_64/wandisco-git-release-6-1.noarch.rpm
#yum -y install http://opensource.wandisco.com/centos/7/git/x86_64/wandisco-git-release-7-1.noarch.rpm
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 2.22.0

安装JDK

  • 下载地址
    • https://www.oracle.com/java/technologies/javase-jdk8-downloads.html
    • jdk-8u241-linux-x64.tar.gz
tar -zxvf jdk-8u241-linux-x64.tar.gz -C /usr/local

配置环境变量

  • /etc/profile添加
#自定义变量
export JAVA_HOME=/usr/local/jdk1.8.0_241
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:${ANDROID_HOME}/build-tools/29.0.3:${ANDROID_HOME}/cmdline-tools/latest/bin:${ANDROID_HOME}/platform-tools:${FLUTTER_HOME}/bin:${PATH}
source /etc/profile

安装Android SDK

  • SDK Tool下载地址
    • https://developer.android.com/studio#downloads
    • Command line tools only
    • commandlinetools-linux-6200805_latest.zip
unzip commandlinetools-linux-6200805_latest.zip -d /usr/local
mkdir -p /usr/local/sdk
cd /usr/local/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

安装flutter

cd /usr/local
#git clone https://github.com/flutter/flutter.git -b v1.14.4
git clone https://github.com/flutter/flutter.git -b stable

验证

flutter doctor -v 
   Woah! You appear to be trying to run flutter as root.
   We strongly recommend running the flutter tool without superuser privileges.
  /
📎
[✓] Flutter (Channel stable, v1.12.13+hotfix.9, on Linux, locale en_US.UTF-8)
    • Flutter version 1.12.13+hotfix.9 at /usr/local/flutter
    • Framework revision f139b11009 (13 days ago), 2020-03-30 13:57:30 -0700
    • Engine revision af51afceb8
    • Dart version 2.7.2

[!] Android toolchain - develop for Android devices (Android SDK version 29.0.3)
    • Android SDK at /usr/local/sdk
    • Android NDK location not configured (optional; useful for native profiling support)
    • Platform android-29, build-tools 29.0.3
    • ANDROID_HOME = /usr/local/sdk
    • Java binary at: /usr/local/jdk1.8.0_241/bin/java
    • Java version Java(TM) SE Runtime Environment (build 1.8.0_241-b07)
    ! Some Android licenses not accepted.  To resolve this, run: flutter doctor --android-licenses

[!] Android Studio (not installed)
    • Android Studio not found; download from https://developer.android.com/studio/index.html
      (or visit https://flutter.dev/setup/#android-setup for detailed instructions).

[!] Connected device
    ! No devices available

! Doctor found issues in 3 categories.
Logo

华为开发者空间,是为全球开发者打造的专属开发空间,汇聚了华为优质开发资源及工具,致力于让每一位开发者拥有一台云主机,基于华为根生态开发、创新。

更多推荐