Commit a5570bf
fix(platform-android): avoid probing physical devices as emulators (#112)
## Description
When we specify an android emulator as the harness runner like below and
connect a physical device, we get the following error.
```js
const config = {
runners: [
androidPlatform({
name: 'android',
device: androidEmulator('Pixel_Tablet_Rootable'),
bundleId: 'com.example',
}),
]
};
export default config;
```
```
SubprocessError: Command failed with exit code 1: ~/Library/Android/sdk/platform-tools/adb -s <device-id> emu avd name
at checkFailure (file:///path/to/node_modules/nano-spawn/source/result.js:40:9)
at getResult (file:///path/to/node_modules/nano-spawn/source/result.js:17:3)
at process.processTicksAndRejections (node:internal/process/task_queues:104:5)
at async Module.getEmulatorName (file:///path/to/node_modules/@react-native-harness/platform-android/dist/adb.js:195:24)
at async getAdbId (file:///path/to/node_modules/@react-native-harness/platform-android/dist/adb-id.js:10:34)
at async getAndroidEmulatorPlatformInstance (file:///path/to/node_modules/@react-native-harness/platform-android/dist/instance.js:108:17)
at async Object.work (file:///path/to/node_modules/@react-native-harness/jest/dist/harness.js:217:36)
at async withPlatformReadyTimeout (file:///path/to/node_modules/@react-native-harness/jest/dist/harness.js:36:16)
at async Promise.all (index 1)
at async file:///path/to/node_modules/@react-native-harness/jest/dist/harness.js:202:24
```
This is just because `getAdbId` tries to get an emulator name from a
physical device.
This patch fixes Android emulator device resolution to skip non-emulator
ADB IDs before querying AVD name. Also adds a focused regression test
suite.
## Testing
I manually tested with that previously problematic situation.
---------
Co-authored-by: Szymon Chmal <szymon@chmal.it>1 parent 8d6a1bb commit a5570bf
3 files changed
Lines changed: 74 additions & 0 deletions
File tree
- .nx/version-plans
- packages/platform-android
- src/__tests__
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
0 commit comments