Search code examples
jestjsreact-nativedetox

DetoxRuntimeError: Failed to run application on the device -Android


Run on Pixel_3_API_29 Android 10.0 x86

I have test this simulator with other react-native code found that Detox work fine.

I'm not sure about my dependencies cause the problem?

$ detox test -c android.emu.debug                        detox[8179] INFO:  [test.js] configuration="android.emu.debug" reportSpecs=true readOnlyEmu=false useCustomLogger=true DETOX_START_TIMESTAMP=1586124976279 node_modules/.bin/jest --config e2e/config.json '--testNamePattern=^((?!:ios:).)*$' --maxWorkers 1 "e2e"

detox[8187] ERROR: [DetoxExportWrapper.js/DETOX_INIT_ERROR] 
 DetoxRuntimeError: Failed to run application on the device

HINT: Most likely, your main activity has crashed prematurely

Native stacktrace dump: 
    at EmulatorDriver._getInstrumentationCrashError (/media/kok/Data/react-native/StellarUI/node_modules/detox/src/devices/drivers/AndroidDriver.js:175:12)
    at EmulatorDriver.instrumentationCloseListener (/media/kok/Data/react-native/StellarUI/node_modules/detox/src/devices/drivers/AndroidDriver.js:142:67)
    at EmulatorDriver._terminateInstrumentation (/media/kok/Data/react-native/StellarUI/node_modules/detox/src/devices/drivers/AndroidDriver.js:166:12)
    at processTicksAndRejections (internal/process/task_queues.js:97:5)
    at ChildProcess.<anonymous> (/media/kok/Data/react-native/StellarUI/node_modules/detox/src/devices/drivers/AndroidDriver.js:260:7) {
  name: 'DetoxRuntimeError'
}
detox[8187] WARN:  [Client.js/PENDING_REQUESTS] App has not responded to the network requests below:
  (id = -1000) isReady: {}

Unresponded network requests might result in timeout errors in Detox tests.
...

Other configuration

"jest": {
    "preset": "react-native"
  },
  "detox": {
    "configurations": {
      "android.emu.debug": {
        "binaryPath": "android/app/build/outputs/apk/debug/app-debug.apk",
        "build": "cd android && ./gradlew assembleDebug assembleAndroidTest -DtestBuildType=debug && cd ..",
        "type": "android.emulator",
        "name": "Pixel_3_API_29"
      },
      "android.emu.release": {
        "binaryPath": "android/app/build/outputs/apk/release/app-release.apk",
        "build": "cd android && ./gradlew assembleRelease assembleAndroidTest -DtestBuildType=release && cd ..",
        "type": "android.emulator",
        "name": "Pixel_3_API_29"
      }
    },
    "test-runner": "jest"
  },

Status:

react-native start ok

react-native run-android ok

detox build ok

detox test debug fail!


Solution

  • I ran into this same error, and it was because I was using a version of detox that did not support Android with react-native 0.62 yet. You need to upgrade detox to 16.2.0.

    See: https://github.com/wix/Detox/releases/tag/16.2.0