温馨提示×

在debian flutter如何发布

小樊
56
2026-10-18 18:10:15
栏目: 智能运维

在 Debian(Linux) 上发布 Flutter 应用,取决于你要发布成什么形式。下面按常见场景说明。


一、发布 Flutter Linux 桌面应用(最常见)

1. 准备环境

确保已启用 Linux 桌面支持:

flutter config --enable-linux-desktop
flutter doctor

安装依赖(Debian/Ubuntu):

sudo apt update
sudo apt install clang cmake ninja-build pkg-config libgtk-3-dev

2. 构建发布版本

flutter build linux --release

构建完成后:

build/linux/x64/release/bundle/

该目录可直接运行:

./build/linux/x64/release/bundle/your_app

3. 打包发布(可选)

方式 A:直接压缩发布

tar czvf yourapp.tar.gz -C build/linux/x64/release bundle

方式 B:制作 Debian 包(.deb)

示例结构:

yourapp/
├── DEBIAN/
│   └── control
└── usr/
    └── local/bin/yourapp

control 示例:

Package: yourapp
Version: 1.0.0
Architecture: amd64
Maintainer: you <you@example.com>
Description: Flutter Linux App

然后:

dpkg-deb --build yourapp

二、发布 Flutter Web 应用

flutter build web --release

发布目录:

build/web/

部署方式:

  • Nginx
  • Apache
  • GitHub Pages
  • 对象存储

Nginx 示例:

server {
    listen 80;
    root /var/www/yourapp;
    index index.html;
    location / {
        try_files $uri $uri/ /index.html;
    }
}

三、发布 Flutter Android(在 Debian 上)

1. 生成签名 key

keytool -genkey -v -keystore key.jks -keyalg RSA -keysize 2048 -validity 10000 -alias key

2. 配置

android/key.properties

storePassword=xxx
keyPassword=xxx
keyAlias=key
storeFile=../key.jks

android/app/build.gradle 配置 signingConfigs

3. 构建

flutter build apk --release
# 或
flutter build appbundle --release

输出:

build/app/outputs/flutter-apk/app-release.apk

四、发布 Flutter iOS(⚠️ 不支持 Debian)

❌ iOS 必须在 macOS 上发布
Debian 无法完成 App Store 发布


五、常见问题

1. 提示缺少 GTK

sudo apt install libgtk-3-dev

2. 无法运行 bundle

确保:

  • 使用相同的架构(x64 / arm64)
  • 依赖库存在

总结

类型 Debian 是否支持 命令
Linux 桌面 ✅ flutter build linux
Web ✅ flutter build web
Android ✅ flutter build apk
iOS ❌ 仅 macOS

如果你能告诉我:

  • 是 桌面 / Web / Android
  • 是否要 deb / AppImage / 发布到商店

我可以给你更精确的发布方案。

0 踩