fix(android): properly handle GOPATH/bin for gomobile in build-apk.bat
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 <noreply@anthropic.com>
This commit is contained in:
parent
131c14742c
commit
d5325efa2a
|
|
@ -89,18 +89,46 @@ if not exist "app\libs\tsslib.aar" (
|
||||||
exit /b 1
|
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
|
:: Check if gomobile is installed
|
||||||
where gomobile >nul 2>nul
|
where gomobile >nul 2>nul
|
||||||
if !errorlevel! neq 0 (
|
if !errorlevel! neq 0 (
|
||||||
echo [INFO] gomobile not found, installing...
|
:: Also check in GOBIN directly
|
||||||
go install golang.org/x/mobile/cmd/gomobile@latest
|
if not exist "!GOBIN_DIR!\gomobile.exe" (
|
||||||
if !errorlevel! neq 0 (
|
echo [INFO] gomobile not found, installing...
|
||||||
echo [ERROR] Failed to install gomobile!
|
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
|
pause
|
||||||
exit /b 1
|
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)
|
:: Get the tsslib directory path (relative to service-party-android)
|
||||||
|
|
@ -125,8 +153,8 @@ if not exist "app\libs\tsslib.aar" (
|
||||||
exit /b 1
|
exit /b 1
|
||||||
)
|
)
|
||||||
|
|
||||||
:: Build the AAR
|
:: Build the AAR (use full path to gomobile)
|
||||||
gomobile bind -target=android -o "..\..\services\service-party-android\app\libs\tsslib.aar" .
|
"!GOBIN_DIR!\gomobile.exe" bind -target=android -o "..\..\services\service-party-android\app\libs\tsslib.aar" .
|
||||||
if !errorlevel! neq 0 (
|
if !errorlevel! neq 0 (
|
||||||
echo [ERROR] gomobile bind failed!
|
echo [ERROR] gomobile bind failed!
|
||||||
popd
|
popd
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue