From d5325efa2a41131a3e30e306308adf433bc9e4ae Mon Sep 17 00:00:00 2001 From: hailin Date: Wed, 31 Dec 2025 23:57:04 -0800 Subject: [PATCH] fix(android): properly handle GOPATH/bin for gomobile in build-apk.bat MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Changes: - Get GOPATH using 'go env GOPATH' command - Add GOPATH/bin to PATH if not already present - Check for gomobile.exe directly in GOBIN directory - Use full path to gomobile.exe for init and bind commands - Add verification that gomobile was installed correctly This fixes the issue where gomobile is installed but not found because GOPATH/bin is not in the system PATH. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 --- .../service-party-android/build-apk.bat | 44 +++++++++++++++---- 1 file changed, 36 insertions(+), 8 deletions(-) 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 fbe60ff9..d152cb79 100644 --- a/backend/mpc-system/services/service-party-android/build-apk.bat +++ b/backend/mpc-system/services/service-party-android/build-apk.bat @@ -89,18 +89,46 @@ if not exist "app\libs\tsslib.aar" ( exit /b 1 ) + :: Get GOPATH for bin directory + for /f "tokens=*" %%G in ('go env GOPATH') do set "GOPATH_DIR=%%G" + if not defined GOPATH_DIR set "GOPATH_DIR=%USERPROFILE%\go" + set "GOBIN_DIR=!GOPATH_DIR!\bin" + + :: Add GOPATH/bin to PATH if not already there + echo !PATH! | findstr /i /c:"!GOBIN_DIR!" >nul 2>nul + if !errorlevel! neq 0 ( + echo [INFO] Adding !GOBIN_DIR! to PATH... + set "PATH=!PATH!;!GOBIN_DIR!" + ) + :: 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! + :: Also check in GOBIN directly + if not exist "!GOBIN_DIR!\gomobile.exe" ( + 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 + ) + ) + + :: Verify gomobile exists after install + if not exist "!GOBIN_DIR!\gomobile.exe" ( + echo [ERROR] gomobile was not installed correctly! + echo Please check your Go installation and GOPATH. + echo Expected location: !GOBIN_DIR!\gomobile.exe pause exit /b 1 ) - :: Initialize gomobile - gomobile init + + echo [INFO] Initializing gomobile... + "!GOBIN_DIR!\gomobile.exe" init + if !errorlevel! neq 0 ( + echo [WARNING] gomobile init failed, but continuing... + ) ) :: Get the tsslib directory path (relative to service-party-android) @@ -125,8 +153,8 @@ if not exist "app\libs\tsslib.aar" ( exit /b 1 ) - :: Build the AAR - gomobile bind -target=android -o "..\..\services\service-party-android\app\libs\tsslib.aar" . + :: Build the AAR (use full path to gomobile) + "!GOBIN_DIR!\gomobile.exe" bind -target=android -o "..\..\services\service-party-android\app\libs\tsslib.aar" . if !errorlevel! neq 0 ( echo [ERROR] gomobile bind failed! popd