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.
This commit is contained in:
@@ -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-<hwid>-<suffix>._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
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user