From cb39f95ff0e1c5bbc4bc6c660e5c775c4b6af2b7 Mon Sep 17 00:00:00 2001 From: Brummel Date: Fri, 24 Apr 2026 13:40:40 +0200 Subject: [PATCH] Export ANDROID_SERIAL for precise device selection This ensures that the `ANDROID_SERIAL` environment variable is exported when `ADB_SERIAL` is set. This is crucial because Android Gradle Plugin's `android.injected.device.serial` property can silently fall back to selecting all attached devices if the serial doesn't match exactly. Exporting `ANDROID_SERIAL` provides a deeper level of filtering for spawned `adb` binaries, maintaining the intended device selection. --- watch/wearos/run.sh | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/watch/wearos/run.sh b/watch/wearos/run.sh index dc747d6..fb178a7 100755 --- a/watch/wearos/run.sh +++ b/watch/wearos/run.sh @@ -308,6 +308,12 @@ apply_target() { fi if [[ -n "$ADB_SERIAL" ]]; then GRADLE_PROPS+=("-Pandroid.injected.device.serial=$ADB_SERIAL") + # AGP's `android.injected.device.serial` silently falls back to "all + # attached devices" when the serial doesn't match exactly (notably + # with mDNS-TLS serials like adb--._adb-tls-connect._tcp). + # ANDROID_SERIAL works one level deeper on every spawned adb binary, + # so the filter holds even when AGP's own matcher doesn't. + export ANDROID_SERIAL="$ADB_SERIAL" fi }