I'm using adb in an automated setup for testing. The following commands, whenever I execute them, sporadically return an exit code of 1 with no indication of errors happening:

  • adb shell settings put global bluetooth_disabled_profiles 1
  • adb shell am force-stop [my app id]
  • adb shell am start -n [my app id]/[app activity id]
  • adb forward --remove tcp:8000
    • interestingly, adding port forwarding using adb forward tcp:8000 tcp:5050 always returns exit code 0
  • adb forward --list
  • adb devices -l

The exit code of the commands listed above is 0 more than 95% of the time it is executed. In the other 1%…5% of executions, adb returns an exit code of 1 but stderr is empty. In all these cases, the command worked fine, i.e. it seems like adb should always return 0.

I wonder why the exit code is non-zero. Should I get some additional info? Or is this a bug in adb? Is this a known issue?

Software info: I've tried different recent versions of adb on Windows 10, e.g.:

adb --version
Android Debug Bridge version 1.0.41
Version 31.0.3-7562133
  • maybe connection/speed issue. you can check logcat or try linux and check dmesg but I guess the only way to figure out is monitoring serial traffic. does it happen on adb over tcpip too?
    – alecxs
    May 12 at 17:34


You must log in to answer this question.

Browse other questions tagged .