From 131c14742ccae6eaa1969b66222eabde510a1da8 Mon Sep 17 00:00:00 2001 From: hailin Date: Wed, 31 Dec 2025 23:48:55 -0800 Subject: [PATCH] feat(android): auto-build tsslib.aar if missing in build-apk.bat MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When tsslib.aar is not found, the build script now automatically: 1. Checks if Go is installed 2. Installs gomobile if not present (go install golang.org/x/mobile/cmd/gomobile@latest) 3. Initializes gomobile if needed 4. Runs go mod tidy in the tsslib directory 5. Builds tsslib.aar using gomobile bind This allows building APKs on any machine with Go installed, without needing to manually compile the TSS library first. Requirements: - Go installed and in PATH - Android NDK (installed via Android SDK) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 --- .../service-party-android/build-apk.bat | 76 +++++++++++++++++++ 1 file changed, 76 insertions(+) diff --git a/backend/mpc-system/services/service-party-android/build-apk.bat b/backend/mpc-system/services/service-party-android/build-apk.bat index b7ace430..fbe60ff9 100644 --- a/backend/mpc-system/services/service-party-android/build-apk.bat +++ b/backend/mpc-system/services/service-party-android/build-apk.bat @@ -75,6 +75,82 @@ echo [INFO] Using SDK from local.properties type local.properties echo. +:: Check and build tsslib.aar if needed +if not exist "app\libs\tsslib.aar" ( + echo [INFO] tsslib.aar not found, attempting to build TSS library... + echo. + + :: Check if Go is installed + where go >nul 2>nul + if !errorlevel! neq 0 ( + echo [ERROR] Go is not installed or not in PATH! + echo Please install Go from https://golang.org/dl/ + pause + exit /b 1 + ) + + :: Check if gomobile is installed + where gomobile >nul 2>nul + if !errorlevel! neq 0 ( + echo [INFO] gomobile not found, installing... + go install golang.org/x/mobile/cmd/gomobile@latest + if !errorlevel! neq 0 ( + echo [ERROR] Failed to install gomobile! + pause + exit /b 1 + ) + :: Initialize gomobile + gomobile init + ) + + :: Get the tsslib directory path (relative to service-party-android) + set "TSSLIB_DIR=..\..\libs\tsslib" + + if not exist "!TSSLIB_DIR!\go.mod" ( + echo [ERROR] TSS library source not found at !TSSLIB_DIR! + echo Please ensure the tsslib source code exists. + pause + exit /b 1 + ) + + echo [INFO] Building tsslib.aar with gomobile... + pushd "!TSSLIB_DIR!" + + :: Run go mod tidy first + go mod tidy + if !errorlevel! neq 0 ( + echo [ERROR] go mod tidy failed! + popd + pause + exit /b 1 + ) + + :: Build the AAR + gomobile bind -target=android -o "..\..\services\service-party-android\app\libs\tsslib.aar" . + if !errorlevel! neq 0 ( + echo [ERROR] gomobile bind failed! + popd + pause + exit /b 1 + ) + + popd + + if exist "app\libs\tsslib.aar" ( + echo [SUCCESS] tsslib.aar built successfully! + for %%F in ("app\libs\tsslib.aar") do echo Size: %%~zF bytes + ) else ( + echo [ERROR] tsslib.aar was not created! + pause + exit /b 1 + ) + echo. +) else ( + echo [INFO] tsslib.aar found, skipping TSS library build + for %%F in ("app\libs\tsslib.aar") do echo Size: %%~zF bytes + echo. +) + :: Parse command line arguments set BUILD_TYPE=all if "%1"=="debug" set BUILD_TYPE=debug