Ubuntu24.04 搭建 Flutter 开发环境
安装 Flutter
Flutter 中文社区下载 https://docs.flutter.cn/get-started/install/linux/android
创建目录 DevTools, 用来存放开发软件
mkdir ~/DevTools
下载 Flutter
wget https://storage.flutter-io.cn/flutter_infra_release/releases/stable/linux/flutter_linux_3.24.5-stable.tar.xz
解压
tar -xvf flutter_linux_3.24.5-stable.tar.xz
将 flutter 软件复制到 DevTools 目录
mv flutter_linux_3.24.4-stable/flutter ~/DevTools
配置系统环境变量
echo 'export PATH=$PATH:~/DevTools/flutter/bin' >> ~/.zshrc
配置 Flutter 镜像
echo 'export PUB_HOSTED_URL=https://mirrors.tuna.tsinghua.edu.cn/dart-pub' >> ~/.zshrc
echo 'export FLUTTER_STORAGE_BASE_URL=https://mirrors.tuna.tsinghua.edu.cn/flutter' >> ~/.zshrc
安装 Android Studio
推荐使用 Jetbrain ToolBox 安装 Android Studio
配置 ADB 环境变量
export 'PATH=$PATH:~/Android/Sdk/platform-tools' >> ~/.zshrc
依赖
使用 Android Studio 安装 cmdline
安装系统依赖
sudo apt install clang cmake ninja-build libgtk-3-dev -y
同意安卓协议,看到提示 **Accept? (y/N): **, 输入 y
, 按 Enter
键, 直到看到提示 All SDK package licenses accepted
flutter doctor --android-licenses
检查依赖是否完全解决
flutter doctor
Flutter assets will be downloaded from https://mirrors.tuna.tsinghua.edu.cn/flutter. Make sure you trust this source!
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.24.4, on Ubuntu 24.04.1 LTS 6.8.0-48-generic, locale en_US.UTF-8)
[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
[✓] Chrome - develop for the web
[✓] Linux toolchain - develop for Linux desktop
[✓] Android Studio (version 2024.2)
[✓] Proxy Configuration
[✓] Connected device (2 available)
[✓] Network resources
• No issues found!
问题修复
错误1
[✗] Linux toolchain - develop for Linux desktop
✗ clang++ is required for Linux development.
It is likely available from your distribution (e.g.: apt install clang), or can be downloaded from
https://releases.llvm.org/
✗ CMake is required for Linux development.
It is likely available from your distribution (e.g.: apt install cmake), or can be downloaded from
https://cmake.org/download/
✗ ninja is required for Linux development.
It is likely available from your distribution (e.g.: apt install ninja-build), or can be downloaded from
https://github.com/ninja-build/ninja/releases
✗ GTK 3.0 development libraries are required for Linux development.
They are likely available from your distribution (e.g.: apt install libgtk-3-dev)
解决方法
sudo apt install clang cmake ninja-build libgtk-3-dev -y
错误2
[!] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
! Some Android licenses not accepted. To resolve this, run: flutter doctor --android-licenses
使用以下命令, 同意协议
flutter doctor --android-licenses
看到提示 **Accept? (y/N): **, 输入 y
, 按 Enter
键, 直到看到提示 All SDK package licenses accepted
错误3
[✗] Chrome - develop for the web (Cannot find Chrome executable at google-chrome)
! Cannot find Chrome. Try setting CHROME_EXECUTABLE to a Chrome executable.
Flutter 开发 Web 项目,需要安装 Google Chrome 浏览器
方式1: 使用 flatpak 安装
flatpak install flathub com.google.Chrome
方式2: 使用 deb 包安装
wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
sudo dpkg -i google-chrome-stable_current_amd64.deb
标签:install,Ubuntu24.04,Flutter,https,Linux,Android,flutter,搭建
From: https://www.cnblogs.com/demodeom/p/18549653