Skip to content

fix(example): fix device detection in build.sh on Linux - #47

Open
mengh04 wants to merge 1 commit into
itsbalamurali:mainfrom
mengh04:fix/build-sh-linux-device-detection
Open

fix(example): fix device detection in build.sh on Linux#47
mengh04 wants to merge 1 commit into
itsbalamurali:mainfrom
mengh04:fix/build-sh-linux-device-detection

Conversation

@mengh04

@mengh04 mengh04 commented Aug 7, 2026

Copy link
Copy Markdown

Problem

example/build.sh checks for a connected Android device/emulator with:

adb devices 2>/dev/null | grep -cE '\t(device|emulator)'

On Linux, GNU grep does not interpret \t as a tab character in -E mode: it emits grep: warning: stray \ before t and matches the literal character t instead. Since adb devices output separates the serial from the state with an actual TAB character, the pattern never matches — so the script always reports ✘ No connected Android device found even when a device/emulator is connected.

(The script was developed on macOS, where BSD grep accepts \t in -E mode, so the bug is Linux-only.)

Fix

Replace \t with the POSIX character class [[:blank:]], which matches a space or tab on both BSD grep (macOS) and GNU grep (Linux):

device_count=$(adb devices 2>/dev/null | grep -cE '[[:blank:]](device|emulator)') || true

Test plan

  • adb devices shows a connected device (fbaa461b1023 device)
  • ./build.sh android --release now proceeds past the device check to Installing & launching on Android

GNU grep does not interpret \t as a tab character in -E mode and warns
"stray \ before t", causing the adb device count to always be 0 on
Linux even when a device/emulator is connected.

Replace it with the POSIX character class [[:blank:]], which works on
both BSD grep (macOS) and GNU grep (Linux).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant