Update: Build scripts and project documentation - 2026-04-03 19:05:44
Some checks failed
flutter analysis / check (push) Has been cancelled
Some checks failed
flutter analysis / check (push) Has been cancelled
This commit is contained in:
132
BUILD_GUIDE.md
Normal file
132
BUILD_GUIDE.md
Normal file
@@ -0,0 +1,132 @@
|
||||
# 构建指南
|
||||
|
||||
## 环境要求
|
||||
|
||||
- Flutter SDK 3.29+
|
||||
- Dart 3.11+
|
||||
- Android SDK
|
||||
- Java 17+
|
||||
|
||||
## 快速开始
|
||||
|
||||
### 1. 安装 Flutter
|
||||
|
||||
```bash
|
||||
# 下载 Flutter SDK
|
||||
cd /tmp
|
||||
curl -o flutter_linux.tar.xz "https://storage.googleapis.com/flutter_infra_release/releases/stable/linux/flutter_linux_3.29.0-stable.tar.xz"
|
||||
|
||||
# 解压到 /opt
|
||||
sudo tar -xf flutter_linux.tar.xz -C /opt
|
||||
|
||||
# 添加 PATH
|
||||
export PATH="$PATH:/opt/flutter/bin"
|
||||
|
||||
# 验证安装
|
||||
flutter doctor
|
||||
```
|
||||
|
||||
### 2. 配置 Android SDK
|
||||
|
||||
确保已安装 Android SDK 并设置 ANDROID_HOME 环境变量:
|
||||
|
||||
```bash
|
||||
export ANDROID_HOME=/path/to/android-sdk
|
||||
export PATH="$PATH:$ANDROID_HOME/cmdline-tools/latest/bin"
|
||||
export PATH="$PATH:$ANDROID_HOME/platform-tools"
|
||||
```
|
||||
|
||||
### 3. 项目设置
|
||||
|
||||
```bash
|
||||
# 进入项目目录
|
||||
cd flutter_openclaw_client
|
||||
|
||||
# 获取依赖
|
||||
flutter pub get
|
||||
|
||||
# 运行代码生成 (如果需要)
|
||||
dart run build_runner build --delete-conflicting-outputs
|
||||
```
|
||||
|
||||
### 4. 构建 APK
|
||||
|
||||
#### Debug 版本
|
||||
```bash
|
||||
flutter build apk --debug
|
||||
```
|
||||
|
||||
#### Release 版本
|
||||
```bash
|
||||
flutter build apk --release
|
||||
```
|
||||
|
||||
输出路径: `build/app/outputs/flutter-apk/app-release.apk`
|
||||
|
||||
#### 指定 ABI
|
||||
```bash
|
||||
# 仅构建 arm64
|
||||
flutter build apk --release --target-platform android-arm64
|
||||
|
||||
# 构建多个 ABI
|
||||
flutter build apk --release --target-platform android-arm,android-arm64,android-x64
|
||||
```
|
||||
|
||||
### 5. 构建 App Bundle (Google Play)
|
||||
|
||||
```bash
|
||||
flutter build appbundle --release
|
||||
```
|
||||
|
||||
输出路径: `build/app/outputs/bundle/release/app-release.aab`
|
||||
|
||||
## 项目结构
|
||||
|
||||
```
|
||||
flutter_openclaw_client/
|
||||
├── android/ # Android 平台代码
|
||||
├── ios/ # iOS 平台代码
|
||||
├── lib/ # Dart 主代码
|
||||
├── linux/ # Linux 平台代码
|
||||
├── macos/ # macOS 平台代码
|
||||
├── packages/ # 本地依赖包
|
||||
├── test/ # 测试代码
|
||||
├── windows/ # Windows 平台代码
|
||||
├── pubspec.yaml # 依赖配置
|
||||
└── build_apk.sh # 构建脚本
|
||||
```
|
||||
|
||||
## 签名配置
|
||||
|
||||
项目已配置调试签名密钥:`android/app/debug.keystore`
|
||||
|
||||
如需使用正式签名,修改 `android/key.properties`:
|
||||
|
||||
```properties
|
||||
storeFile=/path/to/your/keystore.jks
|
||||
storePassword=your_store_password
|
||||
keyAlias=your_key_alias
|
||||
keyPassword=your_key_password
|
||||
```
|
||||
|
||||
## 常见问题
|
||||
|
||||
### Flutter 命令未找到
|
||||
确保已将 Flutter bin 目录添加到 PATH。
|
||||
|
||||
### 构建失败 - 缺少依赖
|
||||
运行 `flutter pub get` 获取依赖。
|
||||
|
||||
### 构建失败 - 代码生成问题
|
||||
运行 `dart run build_runner build --delete-conflicting-outputs`。
|
||||
|
||||
### Android SDK 未找到
|
||||
运行 `flutter doctor` 检查环境配置。
|
||||
|
||||
## 一键构建
|
||||
|
||||
使用提供的构建脚本:
|
||||
|
||||
```bash
|
||||
./build_apk.sh
|
||||
```
|
||||
Reference in New Issue
Block a user