Detox: Error: No instrumentation runner found on device emulator-19386 for package com.package.flavour.test

Describe the bug Followed the instructions and tried to fix this for several days. Running debug test shows Error: No instrumentation runner found on device emulator-19386 for package com.package.flavor.test I’m using flavours.

There are several issues on this that are closed with your bot, with seemingly no answer.

To Reproduce Use flavours and follow the documentation.

Use testBinaryPath because for some reason just having the binaryPath, Detox doesn’t just read it, it adds random folders in the middle of the path you defined:

binaryPath: android/app/build/outputs/apk/androidTest/flavour/debug/app-flavour-debug-androidTest.apk

Error: android/app/build/outputs/apk/androidTest/androidTest/WorkcoDebug/androidTest/app-Workco-debug-androidTest-androidTest.apk’ could not be found, did you run ‘./gradlew assembleAndroidTest’?

With testBinaryPath it uses the correct path but you have to have binaryPath set as well for some reason.

  • I have tested this issue on the latest Detox release and it still reproduces

Steps to reproduce:

  1. Follow documentation
  2. Use on a flavour
  3. See it not work

Expected behavior

Tests run

Device and Verbose Detox Logs

detox[89859] DEBUG: [exec.js/EXEC_CMD, #11] “/Users/me/Library/Android/sdk/platform-tools/adb” -s emulator-19386 shell “pm list packages com.package.flavour.test.test”

Is this meant to have two test?

Environment (please complete the following information):

  • Detox: latest
  • React Native: 0.60.5
  • Node: 12
  • Device: emulator
  • OS: MacOs
  • Test-runner (select one): jest-circus | jest-jasmine2 (deprecated) | mocha jest-circus

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 9
  • Comments: 21

Commits related to this issue

Most upvoted comments

I solved this issue by changing the android configuration as follows. It helps to solve your issue.

 "android.debug": {
      "type": "android.apk",
      "binaryPath": "android/app/build/outputs/apk/debug/app-x86-debug.apk",
      "testBinaryPath": "android/app/build/outputs/apk/androidTest/debug/app-debug-androidTest.apk",
      "build": "cd android && ./gradlew app:assembleDebug app:assembleAndroidTest -DtestBuildType=debug && cd .."
 }

Please be sure that binaryPath indicates your app APK’s path and testBinaryPath indicates your androidTest APK’s path.

Yes, that indeed confirms it:

      "binaryPath": "android/app/build/outputs/apk/androidTest/debug/app-debug-androidTest.apk",

Change it to your app APK’s path.

@anderslundback could you copy&paste your Detox configuration here? According to the logs (and detox code), you’ve erroneously used your test APK for your app’s APK under binaryPath. Please double check that.

Hello, I’m having the same issue.

I have tried running on both an attached android device and various emulators. I have also tried with jest + jest-circus instead of mocha with various versions.

Following the advice of @d4vidi I have also verified that DetoxTest.java is in fact included in my apk. Please see detox logs below with log level: trace. Thank you for taking the time. Please let me know if I can provide any further information.

node: 14.4.0 java: 1.8.0_242 detox: 17.13.2 mocha: 6.1.3 react: 16.13.1 react-native: 0.63.3

detox test -c android.emu.debug --loglevel trace
detox[13864] INFO:  [test.js] mocha --config e2e/.mocharc.json --configuration android.emu.debug --grep :ios: --invert --loglevel trace --use-custom-logger true e2e
detox[13866] INFO:  at node_modules/mocha/lib/reporters/spec.js:49:13 
 
detox[13866] INFO:  at node_modules/mocha/lib/reporters/spec.js:54:13 
 
detox[13866] TRACE: [Detox.js/DETOX_CREATE] created a Detox instance with config:
{"artifactsConfig":{"rootDir":"artifacts/android.emu.debug.2020-12-03 17-26-43Z","plugins":{"log":{"enabled":false,"keepOnlyFailedTestsArtifacts":false},"screenshot":{"enabled":true,"shouldTakeAutomaticSnapshots":false,"keepOnlyFailedTestsArtifacts":false},"video":{"enabled":false,"keepOnlyFailedTestsArtifacts":false},"instruments":{"enabled":false,"keepOnlyFailedTestsArtifacts":false},"timeline":{"enabled":false}},"pathBuilder":{"_rootDir":"artifacts/android.emu.debug.2020-12-03 17-26-43Z"}},"behaviorConfig":{"init":{"reinstallApp":true,"exposeGlobals":true,"launchApp":true},"cleanup":{"shutdownDevice":false}},"cliConfig":{"configuration":"android.emu.debug","loglevel":"trace","useCustomLogger":"true"},"deviceConfig":{"type":"android.emulator","binaryPath":"android/app/build/outputs/apk/androidTest/debug/app-debug-androidTest.apk","build":"cd android ; ./gradlew assembleDebug assembleAndroidTest -DtestBuildType=debug ; cd -","device":{"avdName":"Pixel_API_28_AOSP"}},"runnerConfig":{"testRunner":"mocha","runnerConfig":"e2e/.mocharc.json","specs":"e2e"},"sessionConfig":{"autoStart":true,"server":"ws://localhost:54044","sessionId":"f51fb143-a12a-2cdf-ed2a-716b24182978","debugSynchronization":false},"errorBuilder":{"filepath":"/Users/anders/dev/projects/react-native/detoxrn/.detoxrc.json","contents":{"testRunner":"mocha","runnerConfig":"e2e/.mocharc.json","configurations":{"ios":{"type":"ios.simulator","binaryPath":"SPECIFY_PATH_TO_YOUR_APP_BINARY","device":{"type":"iPhone 11"}},"android.attached.release":{"type":"android.attached","testBinaryPath":"android/app/build/outputs/apk/androidTest/release/app-release-androidTest.apk","build":"cd android && ./gradlew assembleRelease assembleAndroidTest -DtestBuildType=release && cd ..","device":{"avdName":"5200c794439ab5fd"}},"android.attached.debug":{"type":"android.attached","binaryPath":"android/app/build/outputs/apk/androidTest/debug/app-debug-androidTest.apk","build":"cd android ; ./gradlew assembleDebug assembleAndroidTest -DtestBuildType=debug ; cd -","device":{"avdName":"5200c794439ab5fd"}},"android.emu.debug":{"type":"android.emulator","binaryPath":"android/app/build/outputs/apk/androidTest/debug/app-debug-androidTest.apk","build":"cd android ; ./gradlew assembleDebug assembleAndroidTest -DtestBuildType=debug ; cd -","device":{"avdName":"Pixel_API_28_AOSP"}}}},"configurationName":"android.emu.debug"}}
detox[13866] INFO:  [DetoxServer.js] server listening on localhost:54044...
detox[13866] DEBUG: [AsyncWebSocket.js/WEBSOCKET_OPEN] opened web socket to: ws://localhost:54044
detox[13866] TRACE: [AsyncWebSocket.js/WEBSOCKET_SEND] {"type":"login","params":{"sessionId":"f51fb143-a12a-2cdf-ed2a-716b24182978","role":"tester"},"messageId":0}
detox[13866] DEBUG: [DetoxServer.js/LOGIN] role=tester, sessionId=f51fb143-a12a-2cdf-ed2a-716b24182978
detox[13866] DEBUG: [DetoxServer.js/LOGIN_SUCCESS] role=tester, sessionId=f51fb143-a12a-2cdf-ed2a-716b24182978
detox[13866] TRACE: [AsyncWebSocket.js/WEBSOCKET_MESSAGE] {"type":"loginSuccess","params":{"sessionId":"f51fb143-a12a-2cdf-ed2a-716b24182978","role":"tester"},"messageId":0}
 
detox[13866] DEBUG: [exec.js/EXEC_CMD, #0] "/Users/anders/Library/Android/sdk/emulator/emulator" -list-avds --verbose
detox[13866] TRACE: [exec.js/EXEC_SUCCESS, #0] Nexus_5X_API_29_x86
Nexus_7_API_28
Pixel_2_API_29
Pixel_API_28_AOSP

detox[13866] DEBUG: [exec.js/EXEC_CMD, #1] "/Users/anders/Library/Android/sdk/emulator/emulator" -version 
detox[13866] TRACE: [exec.js/EXEC_SUCCESS, #1] Android emulator version 30.2.6.0 (build_id 6962233) (CL:N/A)
Copyright (C) 2006-2017 The Android Open Source Project and many others.
This program is a derivative of the QEMU CPU emulator (www.qemu.org).

  This software is licensed under the terms of the GNU General Public
  License version 2, as published by the Free Software Foundation, and
  may be copied, distributed, and modified under those terms.

  This program is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  GNU General Public License for more details.


detox[13866] DEBUG: [EmulatorVersionResolver.js/EMU_BIN_VERSION_DETECT] Detected emulator binary version { major: 30, minor: 2, patch: 6, toString: [Function: toString] }
detox[13866] DEBUG: [EmulatorDeviceAllocator.js/ALLOCATE_DEVICE] Trying to allocate a device based on "Pixel_API_28_AOSP"
detox[13866] DEBUG: [exec.js/EXEC_CMD, #2] "/Users/anders/Library/Android/sdk/platform-tools/adb"  devices
detox[13866] DEBUG: [exec.js/EXEC_SUCCESS, #2] List of devices attached
emulator-13294  device


detox[13866] TRACE: [EmulatorTelnet.js/TELNET_CONNECTING] port: 13294, host: localhost
detox[13866] DEBUG: [FreeDeviceFinder.js/DEVICE_LOOKUP] Found a matching & free device emulator-13294
detox[13866] DEBUG: [EmulatorDeviceAllocator.js/ALLOCATE_DEVICE] Settled on emulator-13294
detox[13866] DEBUG: [exec.js/EXEC_CMD, #3] "/Users/anders/Library/Android/sdk/platform-tools/adb" -s emulator-13294 shell "getprop dev.bootcomplete"
detox[13866] TRACE: [exec.js/EXEC_SUCCESS, #3] 1

detox[13866] TRACE: [ArtifactsManager.js/LIFECYCLE] artifactsManager.onBootDevice({
  coldBoot: false,
  deviceId: 'emulator-13294',
  type: 'Pixel_API_28_AOSP'
})
detox[13866] DEBUG: [exec.js/EXEC_CMD, #4] "/Users/anders/Library/Android/sdk/platform-tools/adb" -s emulator-13294 shell "getprop ro.build.version.sdk"
detox[13866] TRACE: [exec.js/EXEC_SUCCESS, #4] 28

detox[13866] DEBUG: [exec.js/EXEC_CMD, #5] "/Users/anders/Library/Android/sdk/platform-tools/adb" -s emulator-13294 shell "settings put global animator_duration_scale 0"
detox[13866] TRACE: [exec.js/EXEC_SUCCESS, #5] 
detox[13866] DEBUG: [exec.js/EXEC_CMD, #6] "/Users/anders/Library/Android/sdk/platform-tools/adb" -s emulator-13294 shell "settings put global window_animation_scale 0"
detox[13866] TRACE: [exec.js/EXEC_SUCCESS, #6] 
detox[13866] DEBUG: [exec.js/EXEC_CMD, #7] "/Users/anders/Library/Android/sdk/platform-tools/adb" -s emulator-13294 shell "settings put global transition_animation_scale 0"
detox[13866] TRACE: [exec.js/EXEC_SUCCESS, #7] 
detox[13866] DEBUG: [exec.js/EXEC_CMD, #8] "/Users/anders/Library/Android/sdk/platform-tools/adb" -s emulator-13294 shell "dumpsys power | grep \"^[ ]*m[UW].*=\""
detox[13866] TRACE: [exec.js/EXEC_SUCCESS, #8]   mWakefulness=Awake
  mWakefulnessChanging=false
  mWakeLockSummary=0x0
  mUserActivitySummary=0x1
  mWakeUpWhenPluggedOrUnpluggedConfig=false
  mWakeUpWhenPluggedOrUnpluggedInTheaterModeConfig=false
  mUserActivityTimeoutOverrideFromWindowManager=-1
  mUserInactiveOverrideFromWindowManager=false

detox[13866] DEBUG: [exec.js/EXEC_CMD, #9] "/Users/anders/Library/Android/sdk/build-tools/29.0.3/aapt" dump badging "/Users/anders/dev/projects/react-native/detoxrn/android/app/build/outputs/apk/androidTest/debug/app-debug-androidTest.apk" | grep -e "package: name="
detox[13866] TRACE: [exec.js/EXEC_SUCCESS, #9] package: name='com.detoxrn.test' versionCode='' versionName='' compileSdkVersion='29' compileSdkVersionCodename='10'

detox[13866] TRACE: [ArtifactsManager.js/LIFECYCLE] artifactsManager.onBeforeUninstallApp({ deviceId: 'emulator-13294', bundleId: 'com.detoxrn.test' })
detox[13866] DEBUG: [exec.js/EXEC_CMD, #10] "/Users/anders/Library/Android/sdk/platform-tools/adb" -s emulator-13294 shell "pm list packages com.detoxrn.test"
detox[13866] TRACE: [exec.js/EXEC_SUCCESS, #10] package:com.detoxrn.test

detox[13866] DEBUG: [exec.js/EXEC_CMD, #11] "/Users/anders/Library/Android/sdk/platform-tools/adb" -s emulator-13294 uninstall com.detoxrn.test
detox[13866] TRACE: [exec.js/EXEC_SUCCESS, #11] Success

detox[13866] DEBUG: [exec.js/EXEC_CMD, #12] "/Users/anders/Library/Android/sdk/platform-tools/adb" -s emulator-13294 shell "pm list packages com.detoxrn.test.test"
detox[13866] TRACE: [exec.js/EXEC_SUCCESS, #12] 
detox[13866] DEBUG: [exec.js/EXEC_CMD, #13] "/Users/anders/Library/Android/sdk/platform-tools/adb" -s emulator-13294 shell "rm -fr /data/local/tmp/detox"
detox[13866] TRACE: [exec.js/EXEC_SUCCESS, #13] 
detox[13866] DEBUG: [exec.js/EXEC_CMD, #14] "/Users/anders/Library/Android/sdk/platform-tools/adb" -s emulator-13294 shell "mkdir -p /data/local/tmp/detox"
detox[13866] TRACE: [exec.js/EXEC_SUCCESS, #14] 
detox[13866] DEBUG: [exec.js/EXEC_CMD, #15] "/Users/anders/Library/Android/sdk/platform-tools/adb" -s emulator-13294 push "/Users/anders/dev/projects/react-native/detoxrn/android/app/build/outputs/apk/androidTest/debug/app-debug-androidTest.apk" "/data/local/tmp/detox/Application.apk"
detox[13866] TRACE: [exec.js/EXEC_SUCCESS, #15] /Users/anders/dev/projects/react-native/detoxrn/android/app/build/outputs/apk/androidTest/debug/app-debug-androidTest.apk: 1 file pushed. 8.2 MB/s (1307924 bytes in 0.153s)

detox[13866] DEBUG: [exec.js/EXEC_CMD, #16] "/Users/anders/Library/Android/sdk/platform-tools/adb" -s emulator-13294 shell "pm install -r -g -t /data/local/tmp/detox/Application.apk"
detox[13866] TRACE: [exec.js/EXEC_SUCCESS, #16] Success

detox[13866] DEBUG: [exec.js/EXEC_CMD, #17] "/Users/anders/Library/Android/sdk/platform-tools/adb" -s emulator-13294 push "/Users/anders/dev/projects/react-native/detoxrn/android/app/build/outputs/apk/androidTest/debug/androidTest/app-debug-androidTest-androidTest.apk" "/data/local/tmp/detox/Test.apk"
detox[13866] TRACE: [exec.js/EXEC_SUCCESS, #17] /Users/anders/dev/projects/react-native/detoxrn/android/app/build/outputs/apk/androidTest/debug/androidTest/app-debug-androidTest-androidTest.apk: 1 file pushed. 13.8 MB/s (1307900 bytes in 0.090s)

detox[13866] DEBUG: [exec.js/EXEC_CMD, #18] "/Users/anders/Library/Android/sdk/platform-tools/adb" -s emulator-13294 shell "pm install -r -g -t /data/local/tmp/detox/Test.apk"
detox[13866] TRACE: [exec.js/EXEC_SUCCESS, #18] Success

detox[13866] TRACE: [ArtifactsManager.js/LIFECYCLE] artifactsManager.onBeforeTerminateApp({ deviceId: 'emulator-13294', bundleId: 'com.detoxrn.test' })
detox[13866] DEBUG: [exec.js/EXEC_CMD, #19] "/Users/anders/Library/Android/sdk/platform-tools/adb" -s emulator-13294 shell "am force-stop com.detoxrn.test"
detox[13866] TRACE: [exec.js/EXEC_SUCCESS, #19] 
detox[13866] TRACE: [ArtifactsManager.js/LIFECYCLE] artifactsManager.onTerminateApp({ deviceId: 'emulator-13294', bundleId: 'com.detoxrn.test' })
detox[13866] TRACE: [ArtifactsManager.js/LIFECYCLE] artifactsManager.onBeforeLaunchApp({
  deviceId: 'emulator-13294',
  bundleId: 'com.detoxrn.test',
  launchArgs: {
    detoxServer: 'ws://localhost:54044',
    detoxSessionId: 'f51fb143-a12a-2cdf-ed2a-716b24182978'
  }
})
detox[13866] DEBUG: [exec.js/EXEC_CMD, #20] "/Users/anders/Library/Android/sdk/platform-tools/adb" -s emulator-13294 shell "date +\"%m-%d %T.000\""
detox[13866] TRACE: [exec.js/EXEC_SUCCESS, #20] 12-03 17:27:00.000

detox[13866] DEBUG: [exec.js/EXEC_CMD, #21] "/Users/anders/Library/Android/sdk/platform-tools/adb" -s emulator-13294 reverse tcp:54044 tcp:54044
detox[13866] TRACE: [exec.js/EXEC_SUCCESS, #21] 
detox[13866] DEBUG: [exec.js/EXEC_CMD, #22] "/Users/anders/Library/Android/sdk/platform-tools/adb" -s emulator-13294 shell "pm list instrumentation"
detox[13866] TRACE: [exec.js/EXEC_SUCCESS, #22] instrumentation:com.detoxrn.test/androidx.test.runner.AndroidJUnitRunner (target=com.detoxrn)
instrumentation:org.chromium.webview_shell/.WebViewLayoutTestRunner (target=org.chromium.webview_shell)

detox[13866] ERROR: [DetoxExportWrapper.js/DETOX_INIT_ERROR] 
 Error: No instrumentation runner found on device emulator-13294 for package com.detoxrn.test
    at ADB.getInstrumentationRunner (/Users/anders/dev/projects/react-native/detoxrn/node_modules/detox/src/devices/drivers/android/exec/ADB.js:250:13)
    at async Instrumentation.launch (/Users/anders/dev/projects/react-native/detoxrn/node_modules/detox/src/devices/drivers/android/tools/Instrumentation.js:19:24)
    at async MonitoredInstrumentation.launch (/Users/anders/dev/projects/react-native/detoxrn/node_modules/detox/src/devices/drivers/android/tools/MonitoredInstrumentation.js:18:5)
    at async EmulatorDriver._launchInstrumentationProcess (/Users/anders/dev/projects/react-native/detoxrn/node_modules/detox/src/devices/drivers/android/AndroidDriver.js:256:5)
    at async EmulatorDriver._launchApp (/Users/anders/dev/projects/react-native/detoxrn/node_modules/detox/src/devices/drivers/android/AndroidDriver.js:237:7)
    at async EmulatorDriver.launchApp (/Users/anders/dev/projects/react-native/detoxrn/node_modules/detox/src/devices/drivers/android/AndroidDriver.js:95:5)
    at async Device.launchApp (/Users/anders/dev/projects/react-native/detoxrn/node_modules/detox/src/devices/Device.js:64:23)
    at async Detox._doInit (/Users/anders/dev/projects/react-native/detoxrn/node_modules/detox/src/Detox.js:188:7)
detox[13866] INFO:  at node_modules/mocha/lib/reporters/spec.js:88:13 
   1) "before all" hook in "{root}"
detox[13866] TRACE: [ArtifactsManager.js/LIFECYCLE] artifactsManager.onBeforeCleanup()
detox[13866] DEBUG: [DetoxServer.js/DISCONNECT] role=tester, sessionId=f51fb143-a12a-2cdf-ed2a-716b24182978
detox[13866] DEBUG: [DetoxServer.js/WS_CLOSE] Detox server connections terminated gracefully
detox[13866] INFO:  at node_modules/mocha/lib/reporters/base.js:311:11 
 
detox[13866] INFO:  at node_modules/mocha/lib/reporters/base.js:319:11 
   0 passing (18s)
detox[13866] INFO:  at node_modules/mocha/lib/reporters/base.js:332:13 
   1 failing
detox[13866] INFO:  at node_modules/mocha/lib/reporters/base.js:195:11 
 
detox[13866] INFO:  at node_modules/mocha/lib/reporters/base.js:256:13 
   1) "before all" hook in "{root}":
     Error: No instrumentation runner found on device emulator-13294 for package com.detoxrn.test
      at ADB.getInstrumentationRunner (node_modules/detox/src/devices/drivers/android/exec/ADB.js:250:13)
      at async Instrumentation.launch (node_modules/detox/src/devices/drivers/android/tools/Instrumentation.js:19:24)
      at async MonitoredInstrumentation.launch (node_modules/detox/src/devices/drivers/android/tools/MonitoredInstrumentation.js:18:5)
      at async EmulatorDriver._launchInstrumentationProcess (node_modules/detox/src/devices/drivers/android/AndroidDriver.js:256:5)
      at async EmulatorDriver._launchApp (node_modules/detox/src/devices/drivers/android/AndroidDriver.js:237:7)
      at async EmulatorDriver.launchApp (node_modules/detox/src/devices/drivers/android/AndroidDriver.js:95:5)
      at async Device.launchApp (node_modules/detox/src/devices/Device.js:64:23)
      at async Detox._doInit (node_modules/detox/src/Detox.js:188:7)

detox[13866] INFO:  at node_modules/mocha/lib/reporters/base.js:335:13 
 
detox[13866] INFO:  at node_modules/mocha/lib/reporters/base.js:338:11 
 
detox[13864] ERROR: [cli.js] Error: Command failed: mocha --config e2e/.mocharc.json --configuration android.emu.debug --grep :ios: --invert --loglevel trace --use-custom-logger true e2e

Error: No instrumentation runner found on device emulator-11498 Same issue here, with Pixel 4 emulator and an Expo app.

Any solution ?