Skip to content

ADB commands fail when device serial contains parentheses (mDNS/Wi-Fi) #4937

Description

@yuki2006

Description

When an Android device is connected via Wi-Fi/mDNS, the ADB device serial can contain parentheses, e.g.:

adb-5721009297-Rq3U4s (2)._adb-tls-connect._tcp

This causes all Detox tests to fail with:

/bin/sh: -c: line 0: syntax error near unexpected token `('

Root Cause

In src/devices/common/drivers/android/exec/ADB.js line 391, the device serial is interpolated without quoting:

const serial = `${deviceId ? `-s ${deviceId}` : ''}`;
const cmd = `"${this.adbBin}" ${serial} ${params}`;

The shell interprets ( as a subshell start, causing a parse error.

Note: adbCmdSpawned (line 400) is not affected because it passes arguments as an array to spawn, bypassing shell interpretation.

Fix

Quote the device serial:

const serial = `${deviceId ? `-s "${deviceId}"` : ''}`;

Environment

  • Detox: 20.47.0
  • Device: Physical Android connected via Wi-Fi (mDNS)
  • ADB serial: adb-5721009297-Rq3U4s (2)._adb-tls-connect._tcp
  • Host: macOS

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions