{"record":{"id":"669fc753c2790df4","repo":"golang/go","slug":"adb-exec-out-s-v","errorCode":null,"errorMessage":"adb exec-out %s: %v","messagePattern":"adb exec-out (.+?): (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"misc/go_android_exec/main.go","lineNumber":60,"sourceCode":"\tcmd := adbCmd(\"exec-out\", args)\n\tcmd.Stdout = filter\n\t// If the adb subprocess somehow hangs, go test will kill this wrapper\n\t// and wait for our os.Stderr (and os.Stdout) to close as a result.\n\t// However, if the os.Stderr (or os.Stdout) file descriptors are\n\t// passed on, the hanging adb subprocess will hold them open and\n\t// go test will hang forever.\n\t//\n\t// Avoid that by wrapping stderr, breaking the short circuit and\n\t// forcing cmd.Run to use another pipe and goroutine to pass\n\t// along stderr from adb.\n\tcmd.Stderr = struct{ io.Writer }{os.Stderr}\n\terr := cmd.Run()\n\n\t// Before we process err, flush any further output and get the exit code.\n\texitCode, err2 := filter.Finish()\n\n\tif err != nil {\n\t\treturn 0, fmt.Errorf(\"adb exec-out %s: %v\", args, err)\n\t}\n\treturn exitCode, err2\n}\n\nfunc adb(args ...string) error {\n\tif out, err := adbCmd(args...).CombinedOutput(); err != nil {\n\t\tfmt.Fprintf(os.Stderr, \"adb %s\\n%s\", strings.Join(args, \" \"), out)\n\t\treturn err\n\t}\n\treturn nil\n}\n\nfunc adbCmd(args ...string) *exec.Cmd {\n\tif flags := os.Getenv(\"GOANDROID_ADB_FLAGS\"); flags != \"\" {\n\t\targs = append(strings.Split(flags, \" \"), args...)\n\t}\n\treturn exec.Command(\"adb\", args...)\n}","sourceCodeStart":42,"sourceCodeEnd":78,"githubUrl":"https://github.com/golang/go/blob/b6b368adc57c96c3151d224d172029f233ead2c3/misc/go_android_exec/main.go#L42-L78","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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'."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Verify device connectivity before running go_android_exec.\nfunc adbReady() error {\n    out, err := exec.Command(\"adb\", \"devices\").CombinedOutput()\n    if err != nil {\n        return fmt.Errorf(\"adb unavailable: %w\", err)\n    }\n    if !strings.Contains(string(out), \"\\tdevice\") {\n        return errors.New(\"no authorized device connected\")\n    }\n    return nil\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["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."],"tags":["android","adb","go-test","exec-wrapper","device"],"backgroundTag":null,"analyzedSha":"b6b368adc57c96c3151d224d172029f233ead2c3","analyzedAt":"2026-08-12T00:22:02.250Z","schemaVersion":2},"datasetVersion":"2026-08-12T12:31:55.035Z"}