From fe979566324e4a295cb224e831953557b37939e3 Mon Sep 17 00:00:00 2001 From: iris <2+iris@noreply.localhost> Date: Sun, 30 Aug 2026 13:12:44 -0400 Subject: [PATCH] Take ui-trace to the adb beside it ui-trace found adb on PATH, and this machine's ambient PATH puts the SDK's own platform-tools ahead of ~/.local/bin -- so unless a project's android-env.sh had been sourced into that same shell, ui-trace drove the device through the unwrapped adb and failed with "more than one device" as soon as a second emulator was up. The wrapper installed beside it is the one that knows which emulator this checkout means, so it is now the first candidate rather than a coincidence of PATH order. Co-Authored-By: Claude Opus 5 --- .gitignore | 5 +++++ bin/ui-trace | 14 +++++++++++++- 2 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..204cab6 --- /dev/null +++ b/.gitignore @@ -0,0 +1,5 @@ +# Built by share/ui-trace/build.sh when the source is newer, and pushed to +# the device by ui-trace. Rebuilt on demand, so it is not worth committing -- +# and a jar committed here would go stale against UiTrace.java without saying +# so. +share/ui-trace/uitrace.jar diff --git a/bin/ui-trace b/bin/ui-trace index 3a59415..bebdb03 100755 --- a/bin/ui-trace +++ b/bin/ui-trace @@ -37,7 +37,19 @@ DEVICE_JAR = "/data/local/tmp/uitrace.jar" def find_adb(): - """The real adb, without assuming PATH has been set up for Android.""" + """The adb to drive the device with, without assuming anything about PATH. + + The one installed beside this script comes first, and that is the point + rather than a convenience: it is the wrapper that fills in `-s` from the + checkout you are standing in, and without it a machine with two emulators + attached answers `failed to get feature set: more than one device`. PATH + order cannot be relied on for that -- the SDK's own platform-tools sits + ahead of ~/.local/bin in this machine's ambient PATH, and only a project's + android-env.sh puts it back. + """ + sibling = Path(__file__).resolve().parent / "adb" + if sibling.is_file() and os.access(sibling, os.X_OK): + return str(sibling) for candidate in [ os.environ.get("ADB"), "adb",