golang/go · error
adb exec-out %s: %v
Error message
adb exec-out %s: %v
What it means
Returned by the go_android_exec wrapper (main.go:60) when the underlying `adb exec-out ...` command fails (cmd.Run returned non-nil). The wrapper runs tests on an Android device/emulator via adb; this error surfaces adb-level failures (device not connected, adb not installed, command rejected by device) before any exit-code parsing.
Source
Thrown at misc/go_android_exec/main.go:60
cmd := adbCmd("exec-out", args)
cmd.Stdout = filter
// If the adb subprocess somehow hangs, go test will kill this wrapper
// and wait for our os.Stderr (and os.Stdout) to close as a result.
// However, if the os.Stderr (or os.Stdout) file descriptors are
// passed on, the hanging adb subprocess will hold them open and
// go test will hang forever.
//
// Avoid that by wrapping stderr, breaking the short circuit and
// forcing cmd.Run to use another pipe and goroutine to pass
// along stderr from adb.
cmd.Stderr = struct{ io.Writer }{os.Stderr}
err := cmd.Run()
// Before we process err, flush any further output and get the exit code.
exitCode, err2 := filter.Finish()
if err != nil {
return 0, fmt.Errorf("adb exec-out %s: %v", args, err)
}
return exitCode, err2
}
func adb(args ...string) error {
if out, err := adbCmd(args...).CombinedOutput(); err != nil {
fmt.Fprintf(os.Stderr, "adb %s\n%s", strings.Join(args, " "), out)
return err
}
return nil
}
func adbCmd(args ...string) *exec.Cmd {
if flags := os.Getenv("GOANDROID_ADB_FLAGS"); flags != "" {
args = append(strings.Split(flags, " "), args...)
}
return exec.Command("adb", args...)
}View on GitHub (pinned to b6b368adc5)
Solutions
- Run `adb devices` and confirm your device/emulator shows as 'device' (not 'offline' or 'unauthorized').
- Ensure adb is installed and on PATH: `which adb`.
- Accept the RSA authorization prompt on the physical device, or restart adb: `adb kill-server && adb start-server`.
- Re-run the test once `adb exec-out echo ok` returns 'ok'.
Defensive patterns
Strategy: validation
Validate before calling
// Verify device connectivity before running go_android_exec.
func adbReady() error {
out, err := exec.Command("adb", "devices").CombinedOutput()
if err != nil {
return fmt.Errorf("adb unavailable: %w", err)
}
if !strings.Contains(string(out), "\tdevice") {
return errors.New("no authorized device connected")
}
return nil
} Prevention
- Run `adb devices` before `go test` to confirm a device shows as 'device'.
- Accept the RSA authorization prompt on first connect.
- Keep adb server healthy: `adb kill-server && adb start-server` on weirdness.
When it happens
Trigger: Running `go test` (or go_android_exec) against an Android target with GOOS=android while adb cannot execute the command: device offline, unauthorized, adb server down, adb binary missing from PATH, or the device rejected the exec-out invocation.
Common situations: No emulator running or physical device unplugged; ADB authorization dialog not accepted on the device; mismatched adb/server versions; ANDROID_ADB_DEVICE / GOANDROID_ADDEVICE env mis-set; developer forgot to `adb start-server` or the device is in an unauthorized state.
Related errors
- no exit code (in %q)
- bad exit code: %v (in %q)
- xcrun simctl install booted %q: %v
- xcrun simctl launch booted %q: %v
- failed to locate cmd/go for target platform
AI-assisted analysis of golang/go@b6b368adc5 (2026-08-12).
Data as JSON: /api/errors/669fc753c2790df4.
Report an issue: GitHub.