diff --git a/cmd/clawdroid/main.go b/cmd/clawdroid/main.go index 65f9e3857..857d3275e 100644 --- a/cmd/clawdroid/main.go +++ b/cmd/clawdroid/main.go @@ -13,6 +13,7 @@ import ( "fmt" "io" "io/fs" + "net" "os" "os/signal" "path/filepath" @@ -114,6 +115,16 @@ func copyDirectory(src, dst string) error { }) } +func init() { + // Override DNS resolver for CGO_ENABLED=0 builds (Android APK). + // The pure-Go resolver falls back to [::1]:53 on Android because + // /etc/resolv.conf does not exist. When CGO is enabled (Termux), + // the cgo resolver is used instead and this Dial is never called. + net.DefaultResolver.Dial = func(ctx context.Context, network, address string) (net.Conn, error) { + return (&net.Dialer{}).DialContext(ctx, "udp", "8.8.8.8:53") + } +} + func main() { if len(os.Args) < 2 { printHelp()