### Describe the bug
We upgraded our Detox machine to the new M1 Mac mini and⦠ran into this issue. `detox build -c android.emu.debug` succeeds without problems. `detox test -c android.emu.debug` starts but then hangs when the emulator window opens. The app does not launch. Here is the printout.
```
detox test -c android.emu.debug --loglevel trace --record-logs all
detox[21491] INFO: [test.js] DETOX_CONFIGURATION="android.emu.debug" DETOX_FORCE_ADB_INSTALL=false DETOX_LOGLEVEL="trace" DETOX_READ_ONLY_EMU=false DETOX_RECORD_LOGS="all" DETOX_REPORT_SPECS=true DETOX_START_TIMESTAMP=1620319503548 DETOX_USE_CUSTOM_LOGGER=true jest --config e2e/config.json --testNamePattern '^((?!:ios:).)*$' --maxWorkers 1 e2e
detox[21492] TRACE: [DETOX_CREATE] created a Detox instance with config:
{"artifactsConfig":{"rootDir":"artifacts/android.emu.debug.2021-05-06 16-45-03Z","plugins":{"log":{"enabled":true,"keepOnlyFailedTestsArtifacts":false},"screenshot":{"enabled":true,"shouldTakeAutomaticSnapshots":false,"keepOnlyFailedTestsArtifacts":false},"video":{"enabled":false,"keepOnlyFailedTestsArtifacts":false},"instruments":{"enabled":false,"keepOnlyFailedTestsArtifacts":false},"timeline":{"enabled":false},"uiHierarchy":{"enabled":false,"keepOnlyFailedTestsArtifacts":false}},"pathBuilder":{"_rootDir":"artifacts/android.emu.debug.2021-05-06 16-45-03Z"}},"appsConfig":{"default":{"type":"android.apk","binaryPath":"android/app/build/outputs/apk/dev/debug/app-dev-debug.apk","build":"cd android && ./gradlew assembleDevDebug assembleDevDebugAndroidTest -DtestBuildType=debug && cd .."}},"behaviorConfig":{"init":{"reinstallApp":true,"exposeGlobals":true},"cleanup":{"shutdownDevice":false},"launchApp":"auto"},"cliConfig":{"recordLogs":"all","configuration":"android.emu.debug","forceAdbInstall":"false","loglevel":"trace","useCustomLogger":"true"},"deviceConfig":{"type":"android.emulator","device":{"avdName":"Pixel_4_API_S"}},"runnerConfig":{"testRunner":"jest","runnerConfig":"e2e/config.json","specs":"e2e"},"sessionConfig":{"autoStart":true,"server":"ws://localhost:53897","sessionId":"739c184a-52ba-ed62-53c8-459377c997f9","debugSynchronization":10000},"errorComposer":{"configurationName":"android.emu.debug","filepath":"/Users/fleetback-ci/builds/9J-UT-y5/0/arhs-fleetback/fleetback-app-react/.detoxrc.json","contents":{"testRunner":"jest","runnerConfig":"e2e/config.json","configurations":{"ios.sim.debug":{"binaryPath":"ios/build/Build/Products/Debug-iphonesimulator/Fleetback DEV.app","build":"xcodebuild -workspace ios/FleetbackApp.xcworkspace -scheme FleetbackApp-DEV -configuration Debug -sdk iphonesimulator -derivedDataPath ios/build","type":"ios.simulator","device":{"type":"iPhone 11"}},"ios.sim.release":{"binaryPath":"ios/build/Build/Products/Release-iphonesimulator/Fleetback DEV.app","build":"xcodebuild -workspace ios/FleetbackApp.xcworkspace -scheme FleetbackApp-DEV-release -configuration Release -sdk iphonesimulator -derivedDataPath ios/build","type":"ios.simulator","device":{"type":"iPhone 11"}},"android.emu.debug":{"binaryPath":"android/app/build/outputs/apk/dev/debug/app-dev-debug.apk","build":"cd android && ./gradlew assembleDevDebug assembleDevDebugAndroidTest -DtestBuildType=debug && cd ..","type":"android.emulator","device":{"avdName":"Pixel_4_API_S"}},"android.emu.release":{"binaryPath":"android/app/build/outputs/apk/dev/release/app-dev-release.apk","build":"cd android && ./gradlew assembleDevRelease assembleDevReleaseAndroidTest -DtestBuildType=release && cd ..","type":"android.emulator","device":{"avdName":"Pixel_4_API_S"}}}},"_extends":false}}
detox[21492] DEBUG: [WSS_CREATE] Detox server listening on localhost:53897...
detox[21492] DEBUG: [WSS_CONNECTION, #53898] registered a new connection.
detox[21492] TRACE: [WS_OPEN] opened web socket to: ws://localhost:53897
detox[21492] TRACE: [WS_SEND] {"type":"login","params":{"sessionId":"739c184a-52ba-ed62-53c8-459377c997f9","role":"tester"},"messageId":0}
detox[21492] TRACE: [WSS_GET_FROM, #53898] {"type":"login","params":{"sessionId":"739c184a-52ba-ed62-53c8-459377c997f9","role":"tester"},"messageId":0}
detox[21492] TRACE: [SESSION_CREATED] created session 739c184a-52ba-ed62-53c8-459377c997f9
detox[21492] TRACE: [WSS_SEND_TO, #tester] {"type":"loginSuccess","params":{"testerConnected":true,"appConnected":false},"messageId":0}
detox[21492] TRACE: [SESSION_JOINED] tester joined session 739c184a-52ba-ed62-53c8-459377c997f9
detox[21492] TRACE: [WS_MESSAGE] {"type":"loginSuccess","params":{"testerConnected":true,"appConnected":false},"messageId":0}
detox[21492] DEBUG: [EXEC_CMD, #0] "/Users/fleetback-ci/Library/Android/sdk/emulator/emulator" -list-avds --verbose
detox[21492] TRACE: [EXEC_SUCCESS, #0] Pixel_4_API_25
Pixel_4_API_S
detox[21492] DEBUG: [EXEC_CMD, #1] "/Users/fleetback-ci/Library/Android/sdk/emulator/emulator" -version
detox[21492] ERROR: [EXEC_FAIL, #1] ""/Users/fleetback-ci/Library/Android/sdk/emulator/emulator" -version " failed with error = ChildProcessError: Command failed: "/Users/fleetback-ci/Library/Android/sdk/emulator/emulator" -version
`"/Users/fleetback-ci/Library/Android/sdk/emulator/emulator" -version ` (exited with error code 255) (code=255), stdout and stderr:
detox[21492] ERROR: [EXEC_FAIL, #1] emulator: Android emulator version 30.3.5.0 (build_id 7036990) (CL:N/A)
emulator: ERROR: can't find the emulator executable.
detox[21492] ERROR: [EXEC_FAIL, #1]
detox[21492] DEBUG: [EMU_BIN_VERSION_DETECT] Detected emulator binary version { major: 30, minor: 3, patch: 5, toString: [Function: toString] }
detox[21492] DEBUG: [ALLOCATE_DEVICE] Trying to allocate a device based on "Pixel_4_API_S"
detox[21492] DEBUG: [EXEC_CMD, #2] "/Users/fleetback-ci/Library/Android/sdk/platform-tools/adb" devices
detox[21492] DEBUG: [EXEC_SUCCESS, #2] List of devices attached
detox[21492] DEBUG: [ALLOCATE_DEVICE] Settled on emulator-17342
detox[21492] DEBUG: [SPAWN_CMD] /Users/fleetback-ci/Library/Android/sdk/emulator/emulator -verbose -no-audio -no-boot-anim -port 17342 @Pixel_4_API_S
RUNS e2e/firstTest.e2e.js
```
Building and running the iOS tests works. Both iOS and Android tests build, run and pass on our Intel MacBooks. I had to patch line 22 of EmulatorVersionResolver.js because the command seems broken but still prints the version so it's easy to workaround.
If you Cmd+Q the emulator, more logs appear. The whole logs are attached to the post.
If you don't have a M1 Mac to reproduce the problem, can you give us some pointers as to why the process can get stuck on the adb command? We can help debug and fix the problem.
### Steps To Reproduce
- [x] I have tested this issue on the latest Detox release and it still reproduces
1. create a basic react native project
2. setup detox
3. patch EmulatorVersionResolver.js with `rawOutput = await (this._emulatorExec.exec(new QueryVersionCommand()).catch(e => e.stdout || e.stderr)) || '';`
4. run `detox build -c android.emu.debug && detox test -c android.emu.debug`
5. it hangs
### Expected behavior
It should launch the app and run the tests.
### Detox Trace-Logs
See attached file [detox_bug.txt](https://github.com/wix/Detox/files/6436273/detox_bug.txt)
### Device logs (adb logcat)
It says `- waiting for device -` and nothing happens. If you need them I can try with Android Studio.
### Environment (please complete the following information):
- Detox: 18.12.2
- React Native: 0.64.1
- Node: v14.16.1
- Device: Emulated Pixel 4 API 31 arm64
- OS: macOS 11.3 on the M1 Mac mini
- Test-runner jest-circus