Files
life-echo/app-android/Makefile
penghanyuan df91719a2f feat: 添加 Android 构建脚本以简化版本管理
- 新增 Makefile,提供构建、清理和安装命令,支持指定版本号和版本代码。
- 更新 build.gradle.kts,支持从命令行参数读取版本号和版本代码,增强构建灵活性。
2026-02-14 10:44:56 +01:00

72 lines
2.0 KiB
Makefile
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.
# Life Echo Android 构建脚本
# 使用方法make release VERSION=1.2.3 CODE=10
# 默认版本号
VERSION ?= 1.0.0
CODE ?= 1
.PHONY: help release debug clean install
help:
@echo "Life Echo Android 构建命令:"
@echo ""
@echo " make release VERSION=1.2.3 CODE=10 - 构建 Release APK指定版本号"
@echo " make debug - 构建 Debug APK"
@echo " make clean - 清理构建文件"
@echo " make install - 安装到连接的设备"
@echo ""
@echo "参数:"
@echo " VERSION - 版本名称,如 1.2.3(默认: $(VERSION)"
@echo " CODE - 版本代码(整数),如 10默认: $(CODE)"
@echo ""
@echo "示例:"
@echo " make release VERSION=2.0.0 CODE=20"
# 构建 Release 版本
release:
@echo "🚀 构建 Release 版本..."
@echo " 版本名称: $(VERSION)"
@echo " 版本代码: $(CODE)"
JAVA_HOME="/Applications/Android Studio.app/Contents/jbr/Contents/Home" ./gradlew assembleRelease \
-PversionName=$(VERSION) \
-PversionCode=$(CODE)
@echo "✅ 构建完成!"
@echo "📦 APK 位置: app/build/outputs/apk/release/岁月留书_v$(VERSION)_release.apk"
# 构建 Debug 版本
debug:
@echo "🔧 构建 Debug 版本..."
./gradlew assembleDebug
@echo "✅ Debug 版本构建完成!"
# 构建 Debug Prod 版本(生产环境调试)
debug-prod:
@echo "🔧 构建 Debug Prod 版本..."
./gradlew assembleDebugProd \
-PversionName=$(VERSION) \
-PversionCode=$(CODE)
@echo "✅ Debug Prod 版本构建完成!"
# 清理构建
clean:
@echo "🧹 清理构建文件..."
./gradlew clean
@echo "✅ 清理完成!"
# 安装到设备
install: release
@echo "📱 安装到设备..."
./gradlew installRelease
@echo "✅ 安装完成!"
# 列出所有构建变体
variants:
@echo "📋 可用的构建变体:"
./gradlew tasks --group=build
# 显示当前版本信息
version:
@echo "当前版本配置:"
@echo " VERSION = $(VERSION)"
@echo " CODE = $(CODE)"