Detox: Android tests fail to start on Bitrise
What happened?
After going through much debugging with Bitrise support we believe there is some kind of issue with the launchApp() function. It’s either timing out or just not running at all.
https://support.bitrise.io/hc/en-us/requests/36123
I ran a “dummy” test with no app launch and that seems to run fine.
Here is the stack dump from when this happens.
Detox v 20.5.0
+------------------------------------------------------------------------------+
| id: script |
| version: 1.1.5 |
| collection: https://github.com/bitrise-io/bitrise-steplib.git |
| toolkit: bash |
| time: 2023-03-13T16:30:23Z |
+------------------------------------------------------------------------------+
| |
+ export APP_MODE=mocked
+ APP_MODE=mocked
+ detox test --configuration android.emu.generic e2e/Regression/helpCenter.e2e.ts --start --record-logs all --loglevel debug --detectOpenHandles --debug-synchronization 5000
16:30:28.636 detox[7923] i ws-server Detox server listening on localhost:34693...
16:30:28.654 detox[7923] B lifecycle jest --config e2e/jest.config.ts --detectOpenHandles e2e/Regression/helpCenter.e2e.ts
16:30:33.037 detox[7923] B ws-server connection :34693<->:56970
16:30:33.198 detox[7935] i child-process:EXEC_CMD "/opt/android-sdk-linux/emulator/emulator" -list-avds --verbose
16:30:33.257 detox[7935] i child-process:EXEC_CMD "/opt/android-sdk-linux/emulator/emulator" -version
16:30:33.589 detox[7935] i device Detected emulator binary version { major: 31, minor: 3, patch: 14, toString: [Function: toString] }
16:30:33.591 detox[7935] i device:ALLOCATE_DEVICE Trying to allocate a device based on "emulator"
16:30:33.594 detox[7935] i child-process:EXEC_CMD "/opt/android-sdk-linux/platform-tools/adb" devices
16:30:33.619 detox[7935] i child-process:EXEC_SUCCESS List of devices attached
emulator-5554 device
16:30:33.642 detox[7935] i device:DEVICE_LOOKUP Found a matching & free device emulator-5554
16:30:33.646 detox[7935] i device:ALLOCATE_DEVICE Settled on emulator-5554
16:30:33.647 detox[7935] i child-process:EXEC_CMD "/opt/android-sdk-linux/platform-tools/adb" -s emulator-5554 shell "getprop dev.bootcomplete"
16:30:33.688 detox[7935] i child-process:EXEC_CMD "/opt/android-sdk-linux/platform-tools/adb" -s emulator-5554 shell "getprop ro.build.version.sdk"
16:30:33.720 detox[7935] i child-process:EXEC_CMD "/opt/android-sdk-linux/platform-tools/adb" -s emulator-5554 shell "settings put global animator_duration_scale 0"
16:30:33.763 detox[7935] i child-process:EXEC_CMD "/opt/android-sdk-linux/platform-tools/adb" -s emulator-5554 shell "settings put global window_animation_scale 0"
16:30:33.804 detox[7935] i child-process:EXEC_CMD "/opt/android-sdk-linux/platform-tools/adb" -s emulator-5554 shell "settings put global transition_animation_scale 0"
16:30:33.849 detox[7935] i child-process:EXEC_CMD "/opt/android-sdk-linux/platform-tools/adb" -s emulator-5554 shell "dumpsys power | grep \"^[ ]*m[UW].*=\""
16:30:33.958 detox[7935] i child-process:EXEC_CMD "/opt/android-sdk-linux/build-tools/33.0.0/aapt" dump badging "/bitrise/src/android/app/build/outputs/apk/qa/debug/app-qa-x86_64-debug.apk"
16:30:33.997 detox[7935] i child-process:EXEC_CMD "/opt/android-sdk-linux/platform-tools/adb" -s emulator-5554 shell "pm list packages com.myapp.app.qa"
16:30:34.041 detox[7935] i child-process:EXEC_CMD "/opt/android-sdk-linux/platform-tools/adb" -s emulator-5554 uninstall com.myapp.app.qa
16:30:34.236 detox[7935] i child-process:EXEC_CMD "/opt/android-sdk-linux/platform-tools/adb" -s emulator-5554 shell "pm list packages com.myapp.app.qa.test"
16:30:34.305 detox[7935] i child-process:EXEC_CMD "/opt/android-sdk-linux/platform-tools/adb" -s emulator-5554 shell "am force-stop com.myapp.app.qa"
16:30:34.358 detox[7935] i child-process:EXEC_CMD "/opt/android-sdk-linux/build-tools/33.0.0/aapt" dump xmlstrings "/bitrise/src/android/app/build/outputs/apk/qa/debug/app-qa-x86_64-debug.apk" AndroidManifest.xml
16:30:34.384 detox[7935] i child-process:EXEC_CMD "/opt/android-sdk-linux/build-tools/33.0.0/aapt" dump xmlstrings "/bitrise/src/android/app/build/outputs/apk/androidTest/qa/debug/app-qa-debug-androidTest.apk" AndroidManifest.xml
16:30:34.409 detox[7935] i child-process:EXEC_CMD "/opt/android-sdk-linux/platform-tools/adb" -s emulator-5554 shell "rm -fr /data/local/tmp/detox"
16:30:34.456 detox[7935] i child-process:EXEC_CMD "/opt/android-sdk-linux/platform-tools/adb" -s emulator-5554 shell "mkdir -p /data/local/tmp/detox"
16:30:34.503 detox[7935] i child-process:EXEC_CMD "/opt/android-sdk-linux/platform-tools/adb" -s emulator-5554 push "/bitrise/src/android/app/build/outputs/apk/qa/debug/app-qa-x86_64-debug.apk" "/data/local/tmp/detox/Application.apk"
16:30:35.475 detox[7935] i child-process:SPAWN_CMD /opt/android-sdk-linux/platform-tools/adb -s emulator-5554 shell pm install -r -g -t /data/local/tmp/detox/Application.apk
16:30:37.181 detox[7935] i child-process:SPAWN_END /opt/android-sdk-linux/platform-tools/adb -s emulator-5554 shell pm install -r -g -t /data/local/tmp/detox/Application.apk exited with code #0
16:30:37.184 detox[7935] i child-process:EXEC_CMD "/opt/android-sdk-linux/platform-tools/adb" -s emulator-5554 push "/bitrise/src/android/app/build/outputs/apk/androidTest/qa/debug/app-qa-debug-androidTest.apk" "/data/local/tmp/detox/Test.apk"
16:30:37.275 detox[7935] i child-process:SPAWN_CMD /opt/android-sdk-linux/platform-tools/adb -s emulator-5554 shell pm install -r -g -t /data/local/tmp/detox/Test.apk
16:30:37.458 detox[7935] i child-process:SPAWN_END /opt/android-sdk-linux/platform-tools/adb -s emulator-5554 shell pm install -r -g -t /data/local/tmp/detox/Test.apk exited with code #0
16:30:37.461 detox[7935] i child-process:EXEC_CMD "/opt/android-sdk-linux/platform-tools/adb" -s emulator-5554 shell "am force-stop com.myapp.app.qa"
16:30:44.214 detox[7935] i child-process:SPAWN_CMD /opt/android-sdk-linux/platform-tools/adb -s emulator-5554 shell "logcat -f /sdcard/163033184_0.log"
16:30:44.230 detox[7935] i child-process:EXEC_CMD "/opt/android-sdk-linux/platform-tools/adb" -s emulator-5554 shell "am force-stop com.myapp.app.qa"
16:30:44.307 detox[7935] i child-process:EXEC_CMD "/opt/android-sdk-linux/platform-tools/adb" -s emulator-5554 shell "date +\"%m-%d %T.000\""
16:30:44.380 detox[7935] i child-process:EXEC_CMD "/opt/android-sdk-linux/platform-tools/adb" -s emulator-5554 reverse tcp:34693 tcp:34693
16:30:44.423 detox[7935] i child-process:EXEC_CMD "/opt/android-sdk-linux/platform-tools/adb" -s emulator-5554 shell "pm list instrumentation"
16:30:44.535 detox[7935] i child-process:SPAWN_CMD /opt/android-sdk-linux/platform-tools/adb -s emulator-5554 shell am instrument -w -r -e detoxServer ws://localhost:34693 -e detoxSessionId 252b5613-e558-e969-b82e-4ba84d4ddd60 -e debug false com.myapp.app.qa.test/androidx.test.runner.AndroidJUnitRunner
16:30:44.540 detox[7935] i child-process:EXEC_CMD "/opt/android-sdk-linux/platform-tools/adb" -s emulator-5554 shell du /sdcard/163033184_0.log
16:30:45.041 detox[7935] i child-process:EXEC_CMD "/opt/android-sdk-linux/platform-tools/adb" -s emulator-5554 shell "ps | grep \"com\.myapp\.app\.qa$\""
16:30:46.314 detox[7935] i child-process:EXEC_CMD "/opt/android-sdk-linux/platform-tools/adb" -s emulator-5554 shell "date +\"%m-%d %T.000\""
16:30:46.402 detox[7935] i child-process:SPAWN_END /opt/android-sdk-linux/platform-tools/adb -s emulator-5554 shell "logcat -f /sdcard/163033184_0.log" terminated with SIGINT
16:30:46.439 detox[7935] i child-process:SPAWN_CMD /opt/android-sdk-linux/platform-tools/adb -s emulator-5554 shell "logcat -T \"03-13 16:30:45.000\" --pid=6834 -f /sdcard/163033184_0.log"
16:30:46.741 detox[7935] i child-process:EXEC_CMD "/opt/android-sdk-linux/platform-tools/adb" -s emulator-5554 shell du /sdcard/163033184_0.log
16:31:32.595 detox[7935] i child-process:SPAWN_END /opt/android-sdk-linux/platform-tools/adb -s emulator-5554 shell am instrument -w -r -e detoxServer ws://localhost:34693 -e detoxSessionId 252b5613-e558-e969-b82e-4ba84d4ddd60 -e debug false com.myapp.app.qa.test/androidx.test.runner.AndroidJUnitRunner exited with code #0
16:31:32.597 detox[7935] i device An error occurred while waiting for the app to become ready. Waiting for disconnection...
error: Failed to run application on the device
HINT: Most likely, your main activity has crashed prematurely.
Native stacktrace dump:
java.lang.RuntimeException: Could not launch intent Intent { act=android.intent.action.MAIN flg=0x14000000 cmp=com.myapp.app.qa/com.myapp.app.MainActivity (has extras) } within 45000 milliseconds. Perhaps the main thread has not gone idle within a reasonable amount of time? There could be an animation or something constantly repainting the screen. Or the activity is doing network calls on creation? See the threaddump logs. For your reference the last time the event queue was idle before your activity launch request was 1678725046008 and now the last time the queue went idle was: 1678725046201. If these numbers are the same your activity might be hogging the event queue.
at androidx.test.runner.MonitoringInstrumentation.startActivitySync(MonitoringInstrumentation.java:509)
at androidx.test.rule.ActivityTestRule.launchActivity(ActivityTestRule.java:376)
at com.wix.detox.Detox.runTests(Detox.java:140)
at com.wix.detox.Detox.runTests(Detox.java:103)
at com.myapp.app.DetoxTest.runDetoxTests(DetoxTest.java:34)
What was the expected behaviour?
No response
Was it tested on latest Detox?
- I have tested this issue on the latest Detox release and it still reproduces.
Did your test throw out a timeout?
- I have followed the instructions under Identifying which synchronization mechanism causes us to wait too much.
Help us reproduce this issue!
No response
In what environment did this happen?
Detox version: 20.5.0 React Native version: 0.70.6 Has Fabric (React Native’s new rendering system) enabled: (yes/no) Node version: Device model: Android version: 31 Test-runner (select one): jest
Detox logs
Detox logs
paste logs here!
Device logs
Device logs
paste your device.log here!
More data, please!
No response
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 25
The issue for us was a hanging animation. Once we implemented mocking and turned off that one offending animation, we are able to run the tests no problem.