hi-client/build_android.sh
2025-10-13 18:08:02 +08:00

83 lines
2.7 KiB
Bash
Executable File
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/bin/bash
# Android 多架构构建脚本
# 支持构建不同架构的 APK
set -e
# 颜色输出
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
NC='\033[0m' # No Color
echo -e "${GREEN}🚀 开始构建 Android APK...${NC}"
# 清理之前的构建
echo -e "${YELLOW}🧹 清理之前的构建...${NC}"
flutter clean
flutter pub get
# 构建发布版本 APK
echo -e "${YELLOW}🔨 构建 Android APK所有架构...${NC}"
flutter build apk --release
# 显示构建结果
echo -e "${GREEN}✅ Android APK 构建完成!${NC}"
echo ""
echo -e "${BLUE}📦 构建产物:${NC}"
echo ""
# Universal APK (包含所有架构)
if [ -f "build/app/outputs/flutter-apk/app-release.apk" ]; then
SIZE=$(du -h "build/app/outputs/flutter-apk/app-release.apk" | cut -f1)
echo -e "${GREEN}✓ Universal APK (所有架构): app-release.apk${NC}"
echo -e " 大小: $SIZE"
echo -e " 路径: build/app/outputs/flutter-apk/app-release.apk"
echo ""
fi
# 32位 ARM (armeabi-v7a)
if [ -f "build/app/outputs/flutter-apk/app-armeabi-v7a-release.apk" ]; then
SIZE=$(du -h "build/app/outputs/flutter-apk/app-armeabi-v7a-release.apk" | cut -f1)
echo -e "${GREEN}✓ 32位 ARM (armeabi-v7a): app-armeabi-v7a-release.apk${NC}"
echo -e " 大小: $SIZE"
echo -e " 路径: build/app/outputs/flutter-apk/app-armeabi-v7a-release.apk"
echo ""
fi
# 64位 ARM (arm64-v8a)
if [ -f "build/app/outputs/flutter-apk/app-arm64-v8a-release.apk" ]; then
SIZE=$(du -h "build/app/outputs/flutter-apk/app-arm64-v8a-release.apk" | cut -f1)
echo -e "${GREEN}✓ 64位 ARM (arm64-v8a): app-arm64-v8a-release.apk${NC}"
echo -e " 大小: $SIZE"
echo -e " 路径: build/app/outputs/flutter-apk/app-arm64-v8a-release.apk"
echo ""
fi
# x86 (32位)
if [ -f "build/app/outputs/flutter-apk/app-x86-release.apk" ]; then
SIZE=$(du -h "build/app/outputs/flutter-apk/app-x86-release.apk" | cut -f1)
echo -e "${GREEN}✓ 32位 x86: app-x86-release.apk${NC}"
echo -e " 大小: $SIZE"
echo -e " 路径: build/app/outputs/flutter-apk/app-x86-release.apk"
echo ""
fi
# x86_64 (64位)
if [ -f "build/app/outputs/flutter-apk/app-x86_64-release.apk" ]; then
SIZE=$(du -h "build/app/outputs/flutter-apk/app-x86_64-release.apk" | cut -f1)
echo -e "${GREEN}✓ 64位 x86_64: app-x86_64-release.apk${NC}"
echo -e " 大小: $SIZE"
echo -e " 路径: build/app/outputs/flutter-apk/app-x86_64-release.apk"
echo ""
fi
echo -e "${BLUE}📝 说明:${NC}"
echo " • Universal APK: 适用于所有设备,但体积最大"
echo " • armeabi-v7a: 适用于 32位 ARM 设备(较旧的设备)"
echo " • arm64-v8a: 适用于 64位 ARM 设备(现代设备,推荐)"
echo ""
echo -e "${GREEN}🎉 构建完成!${NC}"