Detox: Detox tests don't run in Android release mode - React Native 0.59

Describe the bug Detox does not run test in Android release mode. Latest versions of both Detox + React Native. The test will hang until it hits the jest timeout and then fail.

To Reproduce Create a clean install of the latest react native. Set up detox. Everything works except for release mode in Android. See example repo where issue is reproduced: https://github.com/jasonhealy/react-native-detox

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

Expected behavior The tests should run in android release mode.

Environment (please complete the following information):

  • Detox: 12.11.0
  • React Native: 0.59.9
  • Node: 8.11.4
  • Device: Android Stock Emulator
  • OS: MacOS

Device and Verbose Detox Logs

detox[89662] INFO:  [DetoxServer.js] server listening on localhost:49694...
detox[89662] DEBUG: [AsyncWebSocket.js/WEBSOCKET_OPEN] opened web socket to: ws://localhost:49694
detox[89662] TRACE: [AsyncWebSocket.js/WEBSOCKET_SEND] {"type":"login","params":{"sessionId":"67ad6740-d299-f127-cdf7-72d96
443097a","role":"tester"},"messageId":0}
detox[89662] DEBUG: [DetoxServer.js/LOGIN] role=tester, sessionId=67ad6740-d299-f127-cdf7-72d96443097a
detox[89662] DEBUG: [DetoxServer.js/LOGIN_SUCCESS] role=tester, sessionId=67ad6740-d299-f127-cdf7-72d96443097a
detox[89662] TRACE: [AsyncWebSocket.js/WEBSOCKET_MESSAGE] {"type":"loginSuccess","params":{"sessionId":"67ad6740-d299-f127-
cdf7-72d96443097a","role":"tester"},"messageId":0}
 
detox[89662] DEBUG: [exec.js/EXEC_CMD, #0] /Users/jason/Library/Android/sdk/emulator/emulator -list-avds --verbose
detox[89662] TRACE: [exec.js/EXEC_SUCCESS, #0] DETOX_EMU_API_28
DEV_API_28
Pixel_XL_API_28

detox[89662] DEBUG: [exec.js/EXEC_CMD, #1] /Users/jason/Library/Android/sdk/platform-tools/adb  devices
detox[89662] TRACE: [exec.js/EXEC_SUCCESS, #1] List of devices attached
emulator-5554   device


detox[89662] TRACE: [EmulatorTelnet.js/TELNET_CONNECTING] port: 5554, host: localhost
detox[89662] DEBUG: [exec.js/EXEC_CMD, #2] /Users/jason/Library/Android/sdk/platform-tools/adb -s emulator-5554 shell "getp
rop dev.bootcomplete"
detox[89662] TRACE: [exec.js/EXEC_SUCCESS, #2] 1

detox[89662] TRACE: [ArtifactsManager.js/LIFECYCLE] artifactsManager.onBootDevice({ coldBoot: false, deviceId: 'emulator-55
54' })
detox[89662] DEBUG: [exec.js/EXEC_CMD, #3] /Users/jason/Library/Android/sdk/platform-tools/adb -s emulator-5554 shell "getp
rop ro.build.version.sdk"
detox[89662] TRACE: [exec.js/EXEC_SUCCESS, #3] 28

detox[89662] DEBUG: [exec.js/EXEC_CMD, #4] /Users/jason/Library/Android/sdk/platform-tools/adb -s emulator-5554 shell "dump
sys power | grep \"^[ ]*m[UW].*=\""
detox[89662] TRACE: [exec.js/EXEC_SUCCESS, #4]   mWakefulness=Awake
  mWakefulnessChanging=false
  mWakeLockSummary=0x0
  mUserActivitySummary=0x4
  mWakeUpWhenPluggedOrUnpluggedConfig=false
  mWakeUpWhenPluggedOrUnpluggedInTheaterModeConfig=false
  mUserActivityTimeoutOverrideFromWindowManager=-1
  mUserInactiveOverrideFromWindowManager=false

detox[89662] DEBUG: [exec.js/EXEC_CMD, #5] /Users/jason/Library/Android/sdk/build-tools/29.0.0-rc1/aapt dump badging "/User
s/jason/Code/RNDetox/android/app/build/outputs/apk/release/app-release.apk" | grep -e "package: name="
detox[89662] TRACE: [exec.js/EXEC_SUCCESS, #5] package: name='com.rndetox' versionCode='1' versionName='1.0' compileSdkVers
ion='28' compileSdkVersionCodename='9'

detox[89662] TRACE: [ArtifactsManager.js/LIFECYCLE] artifactsManager.onBeforeUninstallApp({ deviceId: 'emulator-5554', bund
leId: 'com.rndetox' })
detox[89662] DEBUG: [exec.js/EXEC_CMD, #6] /Users/jason/Library/Android/sdk/platform-tools/adb -s emulator-5554 shell "pm l
ist packages com.rndetox"
detox[89662] TRACE: [exec.js/EXEC_SUCCESS, #6] package:com.rndetox
package:com.rndetox.test

detox[89662] DEBUG: [exec.js/EXEC_CMD, #7] /Users/jason/Library/Android/sdk/platform-tools/adb -s emulator-5554 uninstall c
om.rndetox
detox[89662] TRACE: [exec.js/EXEC_SUCCESS, #7] Success

detox[89662] DEBUG: [exec.js/EXEC_CMD, #8] /Users/jason/Library/Android/sdk/platform-tools/adb -s emulator-5554 shell "pm l
ist packages com.rndetox.test"
detox[89662] TRACE: [exec.js/EXEC_SUCCESS, #8] package:com.rndetox.test

detox[89662] DEBUG: [exec.js/EXEC_CMD, #9] /Users/jason/Library/Android/sdk/platform-tools/adb -s emulator-5554 uninstall c
om.rndetox.test
detox[89662] TRACE: [exec.js/EXEC_SUCCESS, #9] Success

detox[89662] DEBUG: [exec.js/EXEC_CMD, #10] /Users/jason/Library/Android/sdk/platform-tools/adb -s emulator-5554 install -r
 -g -t "/Users/jason/Code/RNDetox/android/app/build/outputs/apk/release/app-release.apk"
detox[89662] TRACE: [exec.js/EXEC_SUCCESS, #10] Performing Streamed Install
Success

detox[89662] DEBUG: [exec.js/EXEC_CMD, #11] /Users/jason/Library/Android/sdk/platform-tools/adb -s emulator-5554 install -r
 -g -t "/Users/jason/Code/RNDetox/android/app/build/outputs/apk/androidTest/release/app-release-androidTest.apk"
detox[89662] TRACE: [exec.js/EXEC_SUCCESS, #11] Performing Streamed Install
Success

detox[89662] TRACE: [ArtifactsManager.js/LIFECYCLE] artifactsManager.onBeforeTerminateApp({ deviceId: 'emulator-5554', bund
leId: 'com.rndetox' })
detox[89662] DEBUG: [exec.js/EXEC_CMD, #12] /Users/jason/Library/Android/sdk/platform-tools/adb -s emulator-5554 shell "am 
force-stop com.rndetox"
detox[89662] TRACE: [exec.js/EXEC_SUCCESS, #12] 
detox[89662] TRACE: [ArtifactsManager.js/LIFECYCLE] artifactsManager.onBeforeLaunchApp({ deviceId: 'emulator-5554',
  bundleId: 'com.rndetox',
  launchArgs: 
   { detoxServer: 'ws://localhost:49694',
     detoxSessionId: '67ad6740-d299-f127-cdf7-72d96443097a' } })
detox[89662] DEBUG: [exec.js/EXEC_CMD, #13] /Users/jason/Library/Android/sdk/platform-tools/adb -s emulator-5554 shell "dat
e +\"%m-%d %T.000\""
detox[89662] TRACE: [exec.js/EXEC_SUCCESS, #13] 06-14 01:12:22.000

detox[89662] DEBUG: [exec.js/EXEC_CMD, #14] /Users/jason/Library/Android/sdk/platform-tools/adb -s emulator-5554 shell "pm 
list instrumentation"
detox[89662] TRACE: [exec.js/EXEC_SUCCESS, #14] instrumentation:com.rndetox.test/androidx.test.runner.AndroidJUnitRunner (t
arget=com.rndetox)
instrumentation:org.chromium.webview_shell/.WebViewLayoutTestRunner (target=org.chromium.webview_shell)

detox[89662] DEBUG: [exec.js/SPAWN_CMD, #15] [pid=89682] /Users/jason/Library/Android/sdk/platform-tools/adb -s emulator-55
54 shell am instrument -w -r -e detoxServer ws://localhost:49694 -e detoxSessionId 67ad6740-d299-f127-cdf7-72d96443097a -e 
debug ZmFsc2U= com.rndetox.test/androidx.test.runner.AndroidJUnitRunner
detox[89662] TRACE: [exec.js/SPAWN_STDOUT, #15] INSTRUMENTATION_STATUS: class=com.rndetox.DetoxTest
INSTRUMENTATION_STATUS: current=1
INSTRUMENTATION_STATUS: id=AndroidJUnitRunner
INSTRUMENTATION_STATUS: numtests=1
INSTRUMENTATION_STATUS: stream=
com.rndetox.DetoxTest:
INSTRUMENTATION_STATUS: test=runDetoxTests
INSTRUMENTATION_STATUS_CODE: 1

detox[89662] DEBUG: [exec.js/EXEC_CMD, #16] /Users/jason/Library/Android/sdk/platform-tools/adb -s emulator-5554 shell "ps 
| grep \"com\.rndetox$\""
detox[89662] TRACE: [exec.js/EXEC_SUCCESS, #16] u0_a103       8089  1694 1527688 146268 0                   0 S com.rndetox

detox[8089] TRACE: [ArtifactsManager.js/LIFECYCLE] artifactsManager.onLaunchApp({ deviceId: 'emulator-5554',
  bundleId: 'com.rndetox',
  launchArgs: 
   { detoxServer: 'ws://localhost:49694',
     detoxSessionId: '67ad6740-d299-f127-cdf7-72d96443097a' },
  pid: 8089 })
detox[89662] TRACE: [AsyncWebSocket.js/WEBSOCKET_SEND] {"type":"isReady","params":{},"messageId":-1000}
detox[89662] TRACE: [DetoxServer.js/MESSAGE] role=tester action=isReady (sessionId=67ad6740-d299-f127-cdf7-72d96443097a)
detox[89662] DEBUG: [DetoxServer.js/CANNOT_FORWARD] role=testee not connected, cannot fw action (sessionId=67ad6740-d299-f1
27-cdf7-72d96443097a)

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Reactions: 18
  • Comments: 28

Most upvoted comments

I’m having a similar issue with react-native 0.60.0 with API 29.

Detox runs in debug mode but not in release mode. The app is installed correctly on the simulator and is a working copy (functions worked when click around manually)

However, after the app is launched, there is an error [DetoxServer.js/CANNOT_FORWARD] role=testee not connected, cannot fw action

Does detox requires the metro bundler for release builds? In my case, even when the metro bundler is running in the background, there is no response.

Can also confirm that downgrading Emulator Target API to 28 or lower fixes the issue for us.

A little bit of evidence from my tests: I can reproduce the error on an Android 9.0 emulator, but the exact same app works fine on an Android 8.0 emulator. I’ve been using these docker images for testing (budtmo/docker-android-x86-9.0 and budtmo/docker-android-x86-8.0).

Just an update here: It seems like there may be an underlying environmental issue causing this. A colleague of mine is able to run tests against RN0.59, while I’m not on a project with identical setups. We’ll dig deeper to see if we can find any issues.

I’m having the same issue in debug mode as well. Any update on this? Targeting API to 28 or lower does not work for us

I think it’s related to #1297

As workaround change targetSdkVersion as stated here

Same problem here. Has anybody found a solution or a work-around?