fix: update Android build process to use cgo for DNS resolution and streamline HTTP client configuration

This commit is contained in:
Sarto
2026-04-30 20:52:06 +03:30
parent 503852fce9
commit 7834f0f598
2 changed files with 36 additions and 68 deletions
+13 -5
View File
@@ -91,12 +91,20 @@ jobs:
if [ "${{ matrix.goos }}" = "android" ]; then
BUILD_MODE="-buildmode=pie"
fi
# Go's internal linker can do PIE for android/arm64 with CGO=0,
# but android/arm (32-bit) needs an external linker via cgo.
# Wire the NDK clang for the v7 build; arm64 stays CGO-less.
if [ "${{ matrix.goos }}" = "android" ] && [ "${{ matrix.goarch }}" = "arm" ]; then
# Android: build with cgo so DNS resolution goes through bionic
# libc / netd instead of Go's pure-Go resolver, which on Android
# finds /etc/resolv.conf empty and dies with "[::1]:53 connection
# refused". Wire the right NDK clang per architecture.
if [ "${{ matrix.goos }}" = "android" ]; then
export CGO_ENABLED=1
export CC="$ANDROID_NDK_LATEST_HOME/toolchains/llvm/prebuilt/linux-x86_64/bin/armv7a-linux-androideabi26-clang"
case "${{ matrix.goarch }}" in
arm)
export CC="$ANDROID_NDK_LATEST_HOME/toolchains/llvm/prebuilt/linux-x86_64/bin/armv7a-linux-androideabi26-clang"
;;
arm64)
export CC="$ANDROID_NDK_LATEST_HOME/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android26-clang"
;;
esac
test -x "$CC" || { echo "NDK clang not found at $CC"; exit 1; }
fi
if [ "${{ matrix.goos }}" = "android" ] && [ "${{ matrix.goarch }}" = "arm64" ]; then