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