UI testing with Detox for Expo Android: Error: No instrumentation runner found on device emulator.

I’ve been trying to get detox working with our Expo Android app and even though I made some progress, have been stuck with this error for 2-3 days:

No instrumentation runner found on device emulator-5554 for package host.exp.exponent

These are the steps that I tried:

➜ npm install -g detox-cli
➜ npm install detox --save-dev
➜ npm install mocha --save-dev
➜ npm i detox-expo-helpers --save-dev
➜ detox init -r mocha
➜ mkdir bin

➜ ls
App.js    bin                   native-base-theme  package-lock.json  __tests__
app.json  e2e                   node_modules       README.md          themes
assets    google-services.json  package.json       src

➜ mv ~/.expo/android-apk-cache/Exponent-2.11.2.apk bin/
➜ mv bin/Exponent-2.11.2.apk bin/Exponent.apk

Here is the package.json:

{
  "name": "abc",
  "version": "0.1.0",
  "private": true,
  "main": "node_modules/expo/AppEntry.js",
  "scripts": {
    "start": "exp start",
    "eject": "exp eject",
    "android": "exp android",
    "ios": "exp ios",
    "test": "node node_modules/jest/bin/jest.js --watch"
  },
  "jest": {
    "preset": "jest-expo",
    "transformIgnorePatterns": [
      "node_modules/(?!react-native|expo|react-navigation|native-base-shoutem-theme|@shoutem/theme|@shoutem/animation|@shoutem/ui|tcomb-form-native)"
    ]
  },
  "detox": {
    "configurations": {
      "android.emu.debug": {
        "binaryPath": "bin/Exponent.apk",
        "build": "npm run android",
        "type": "android.emulator",
        "name": "New_Device_2_API_26"
      }
    }
  },
  "dependencies": {
    "@expo/vector-icons": "^6.2.1",
    "bunyan": "^1.8.12",
    "expo": "^26.0.0",
    "lodash": "^4.17.5",
    "moment": "^2.20.1",
    "moment-timezone": "^0.5.25",
    "native-base": "^2.6.1",
    "react": "16.3.0-alpha.1",
    "react-native": "https://github.com/expo/react-native/archive/sdk-26.0.0.tar.gz",
    "react-native-device-info": "^0.21.5",
    "react-native-swiper": "^1.5.14",
    "react-navigation": "1.5.8",
    "rn-prompt": "^1.0.3",
    "sentry-expo": "~1.7.0"
  },
  "devDependencies": {
    "babel-plugin-module-resolver": "^3.0.0",
    "detox": "^12.11.1",
    "detox-expo-helpers": "^0.6.0",
    "expo-detox-hook": "^1.0.10",
    "jest-expo": "^22.0.0",
    "mocha": "^6.1.4",
    "react-addons-test-utils": "^15.6.2",
    "react-dom": "^16.2.0",
    "react-native-scripts": "1.7.0",
    "react-test-renderer": "16.0.0-beta.5"
  }
}

After all of this, while trying detox test for the first time, I was met with the error:

Error: app binary not found at '../android/app/build/outputs/apk/debug/app-debug.apk', did you build it?

As a quick fix, just to get the initial tests running so that I can validate that this entire setup works, I went ahead and edited the ../node_modules/detox/src/devices/android/APKPath.js directly and hardcoded the path to the binary:

const testApkPath = '../bin/Exponent.apk';

That specific error was fixed for the time being after that. However, the next time running detox test started giving me the error of this post:

➜ detox test
detox[13573] INFO:  [test.js] node_modules/.bin/mocha --opts e2e/mocha.opts --configuration android.emu.debug --grep :ios: --invert --artifacts-location "artifacts/android.emu.debug.2019-06-19 13-31-01Z" "e2e"


detox[13586] INFO:  [DetoxServer.js] server listening on localhost:45523...
detox[13586] ERROR: [index.js/DETOX_INIT_ERROR] 
 Error: No instrumentation runner found on device emulator-5554 for package host.exp.exponent
    at ADB.getInstrumentationRunner (../node_modules/detox/src/devices/android/ADB.js:253:13)
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:188:7)
  1) "before all" hook in "{root}"

  0 passing (38s)
  1 failing

  1) "before all" hook in "{root}":
     Error: No instrumentation runner found on device emulator-5554 for package host.exp.exponent
      at ADB.getInstrumentationRunner (node_modules/detox/src/devices/android/ADB.js:253:13)
      at <anonymous>
      at process._tickCallback (internal/process/next_tick.js:188:7)


detox[13573] ERROR: [cli.js] Error: Command failed: node_modules/.bin/mocha --opts e2e/mocha.opts --configuration android.emu.debug --grep :ios: --invert --artifacts-location "artifacts/android.emu.debug.2019-06-19 13-31-01Z" "e2e"

I am not an expert, but after reading around, something tells me that this info also might be relevant:

➜ adb shell pm list instrumentation
instrumentation:com.android.emulator.smoketests/android.support.test.runner.AndroidJUnitRunner (target=com.android.emulator.smoketests)
instrumentation:com.android.smoketest.tests/com.android.smoketest.SmokeTestRunner (target=com.android.smoketest)
instrumentation:com.example.android.apis/.app.LocalSampleInstrumentation (target=com.example.android.apis)
instrumentation:org.chromium.webview_shell/.WebViewLayoutTestRunner (target=org.chromium.webview_shell)

Please let me know if you need any more info in order to help. Any pointers or help would be greatly appreciated. Thank you so much! :slight_smile:

I’m having the same problem and will appreciate any ideas how to proceed.
(commenting it only to extend the period before the issue is automatically closed)

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.