Detox: Running tests on Android gets stuck in the "before all" hook
Description
hey, I am having an issue with running detox on Android. We got it working in iOS and now wanted to add Android tests as well. We use RN 0.49. When I run detox on Android - I get a white screen, and in the console I get stuck in the “before all” hook:
1) "before all" hook
0 passing (3m)
1 failing
1) "before all" hook:
Error: Timeout of 200000ms exceeded. For async tests and hooks, ensure "done()" is called; if returning a Promise, ensure it resolves.
Steps to Reproduce
After following all the steps in the Android guide (and fixing some versions issues, and fixes from the troubleshooting), I tried to run the text:
detox test --configuration android.emu.debug -l verbose
, and got the following logs:
Start
detox-server info 15:56:55: server listening on localhost:64180...
detox verb ws onOpen [object Object]
detox verb ws send: {"type":"login","params":{"sessionId":"5e43bcb5-acd5-0c85-6791-bce08925d109","role":"tester"},"messageId":0}
detox verb ws onMessage: {"type":"loginSuccess","params":{"sessionId":"5e43bcb5-acd5-0c85-6791-bce08925d109","role":"tester"},"messageId":0}
detox verb ws
detox verb 1: /Users/ilonashub/Library/Android/sdk/tools/emulator -list-avds --verbose
detox verb 1: stdout: Nexus_5X_API_23
detox verb 1: stdout: Nexus_5X_API_24
detox verb 1: stdout:
detox verb Emulator stdout: emulator: Android virtual device file at: /Users/ilonashub/.android/avd/Nexus_5X_API_24.ini
detox verb Emulator stdout: emulator: virtual device content at /Users/ilonashub/.android/avd/Nexus_5X_API_24.avd
detox verb Emulator stdout: emulator: virtual device config file: /Users/ilonashub/.android/avd/Nexus_5X_API_24.avd/config.ini
detox verb Emulator stdout: emulator: using core hw config path: /Users/ilonashub/.android/avd/Nexus_5X_API_24.avd/hardware-qemu.ini
detox verb Emulator stdout: emulator: Found AVD target API level: 24
detox verb Emulator stdout: emulator: Read property file at /Users/ilonashub/Library/Android/sdk//system-images/android-24/google_apis_playstore/x86//build.prop
detox verb Emulator stdout: emulator: No boot.prop property file found.
detox verb Emulator stdout: emulator: found skin 'nexus_5x' in directory: /Users/ilonashub/Library/Android/sdk/skins/
detox verb Emulator stdout: emulator: autoconfig: -skin nexus_5x
detox verb Emulator stdout: emulator: autoconfig: -skindir /Users/ilonashub/Library/Android/sdk/skins/
detox verb Emulator stdout: emulator: autoconfig: -kernel /Users/ilonashub/Library/Android/sdk//system-images/android-24/google_apis_playstore/x86//kernel-ranchu
detox verb Emulator stdout: emulator: Target arch = 'x86'
detox verb Emulator stdout: emulator: Auto-config: -qemu -cpu qemu32
detox verb Emulator stdout: emulator: Auto-detect: Kernel image requires new device naming scheme.
detox verb Emulator stdout: emulator: Auto-detect: Kernel does not support YAFFS2 partitions.
detox verb Emulator stdout: emulator: autoconfig: -ramdisk /Users/ilonashub/Library/Android/sdk//system-images/android-24/google_apis_playstore/x86//ramdisk.img
detox verb Emulator stdout: emulator: Using initial system image: /Users/ilonashub/Library/Android/sdk//system-images/android-24/google_apis_playstore/x86//system.img
detox verb Emulator stdout: emulator: No vendor image
detox verb Emulator stdout: emulator: autoconfig: -data /Users/ilonashub/.android/avd/Nexus_5X_API_24.avd/userdata-qemu.img
detox verb Emulator stdout: emulator: autoconfig: -initdata /Users/ilonashub/.android/avd/Nexus_5X_API_24.avd/userdata.img
detox verb Emulator stdout: emulator: autoconfig: -cache /Users/ilonashub/.android/avd/Nexus_5X_API_24.avd/cache.img
detox verb Emulator stdout: emulator: autoconfig: -sdcard /Users/ilonashub/.android/avd/Nexus_5X_API_24.avd/sdcard.img
detox verb Emulator stdout: emulator: Physical RAM size: 1536MB
detox verb Emulator stdout:
detox verb Emulator stdout: emulator: VM heap size 256MB is below hardware specified minimum of 384MB,setting it to that value
detox verb Emulator stdout: emulator: System image is read only
detox verb Emulator stdout: emulator: Found 2 DNS servers: 192.115.106.35 62.219.186.7
detox verb Emulator stdout: emulator: ERROR: There's another emulator instance running with the current AVD 'Nexus_5X_API_24'. Exiting...
detox verb Emulator stdout:
detox verb Emulator stdout:
detox verb 2: /Users/ilonashub/Library/Android/sdk/platform-tools/adb devices
detox verb 2: stdout: List of devices attached
detox verb 2: stdout: emulator-5554 device
detox verb 2: stdout:
detox verb 2: stdout:
detox verb 3: /Users/ilonashub/Library/Android/sdk/platform-tools/adb -s emulator-5554 shell input keyevent 82
detox verb 4: /Users/ilonashub/Library/Android/sdk/platform-tools/adb -s emulator-5554 uninstall com.homeismobile
detox verb 4: stdout: Success
detox verb 4: stdout:
detox verb 5: /Users/ilonashub/Library/Android/sdk/platform-tools/adb -s emulator-5554 uninstall com.homeismobile.test
detox verb 5: stdout: Success
detox verb 5: stdout:
detox verb 6: /Users/ilonashub/Library/Android/sdk/platform-tools/adb -s emulator-5554 install -r -g /Users/ilonashub/homeis/home-is-mobile/android/app/build/outputs/apk/app-debug.apk
detox verb 6: stderr: Success
detox verb 6: stderr:
detox verb 7: /Users/ilonashub/Library/Android/sdk/platform-tools/adb -s emulator-5554 install -r -g /Users/ilonashub/homeis/home-is-mobile/android/app/build/outputs/apk/app-debug-androidTest.apk
detox verb 7: stderr: Success
detox verb 7: stderr:
detox verb 8: /Users/ilonashub/Library/Android/sdk/platform-tools/adb -s emulator-5554 shell am force-stop com.homeismobile
detox verb adb -s emulator-5554 shell am instrument -w -r -e detoxServer ws://localhost:64180 -e detoxSessionId 5e43bcb5-acd5-0c85-6791-bce08925d109 -e debug false com.homeismobile.test/android.support.test.runner.AndroidJUnitRunner
detox verb Instrumentation spawned, childProcess.pid: 27598
detox verb ws send: {"type":"isReady","params":{},"messageId":-1000}
detox verb Instrumentation stdout: INSTRUMENTATION_STATUS: numtests=1
detox verb Instrumentation stdout:
detox verb Instrumentation stdout: INSTRUMENTATION_STATUS: stream=
detox verb Instrumentation stdout: com.homeismobile.DetoxTest:
detox verb Instrumentation stdout: INSTRUMENTATION_STATUS: id=AndroidJUnitRunner
detox verb Instrumentation stdout: INSTRUMENTATION_STATUS: test=runDetoxTests
detox verb Instrumentation stdout: INSTRUMENTATION_STATUS: class=com.homeismobile.DetoxTest
detox verb Instrumentation stdout: INSTRUMENTATION_STATUS: current=1
detox verb Instrumentation stdout: INSTRUMENTATION_STATUS_CODE: 1
detox verb Instrumentation stdout:
1) "before all" hook
0 passing (3m)
1 failing
1) "before all" hook:
Error: Timeout of 200000ms exceeded. For async tests and hooks, ensure "done()" is called; if returning a Promise, ensure it resolves.
detox verb ws send: {"type":"cleanup","params":{"stopRunner":true},"messageId":1}
Detox, Node, Device, Xcode and macOS Versions
- Detox: 5.9.1
- Node: 8.4.0
- Device: nexus_5x_API_24
- Xcode: 9.1
- macOS: 10.12.6
Device and verbose Detox logs
from the adb logcat I could see a few errors - which I think are unrelated to the issue (for example pushwoosh error shouldn’t prevent the app to be up I think. So I added some of the logs with warnings/errors here.
......
11-09 16:03:19.386 2145 2681 E Volley : [147] BasicNetwork.performRequest: Unexpected response code 307 for https://android.googleapis.com/nova/herrevad/network_quality_info
11-09 16:03:19.391 2145 5906 W Herrevad: [481] RemoteReportsRefreshChimeraService.a: java.util.concurrent.ExecutionException: com.android.volley.ServerError
11-09 16:03:19.391 2145 5906 W Herrevad: java.util.concurrent.ExecutionException: com.android.volley.ServerError
11-09 16:03:19.391 2145 5906 W Herrevad: at com.android.volley.toolbox.RequestFuture.a(:com.google.android.gms@11743470:4)
11-09 16:03:19.391 2145 5906 W Herrevad: at com.android.volley.toolbox.RequestFuture.get(:com.google.android.gms@11743470:2)
11-09 16:03:19.391 2145 5906 W Herrevad: at com.google.android.gms.herrevad.services.RemoteReportsRefreshChimeraService.a(:com.google.android.gms@11743470:26)
11-09 16:03:19.391 2145 5906 W Herrevad: at com.google.android.gms.herrevad.services.RemoteReportsRefreshChimeraService.a(:com.google.android.gms@11743470:33)
11-09 16:03:19.391 2145 5906 W Herrevad: at sxf.run(:com.google.android.gms@11743470:1)
11-09 16:03:19.391 2145 5906 W Herrevad: at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
11-09 16:03:19.391 2145 5906 W Herrevad: at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
11-09 16:03:19.391 2145 5906 W Herrevad: at java.lang.Thread.run(Thread.java:761)
11-09 16:03:19.391 2145 5906 W Herrevad: Caused by: com.android.volley.ServerError
11-09 16:03:19.391 2145 5906 W Herrevad: at com.android.volley.toolbox.BasicNetwork.performRequest(:com.google.android.gms@11743470:37)
11-09 16:03:19.391 2145 5906 W Herrevad: at mhc.performRequest(:com.google.android.gms@11743470:4)
11-09 16:03:19.391 2145 5906 W Herrevad: at com.android.volley.NetworkDispatcher.run(:com.google.android.gms@11743470:12)
11-09 16:03:19.444 5829 5900 W System : ClassLoader referenced unknown path: /system/app/Chrome/lib/x86
......
11-09 16:03:19.542 5829 5898 V WebViewChromiumFactoryProvider: Binding Chromium to main looper Looper (main, tid 1) {90d2951}
11-09 16:03:19.691 1944 2248 W Conscrypt: Could not set socket write timeout:
11-09 16:03:19.691 1944 2248 W Conscrypt: java.lang.reflect.Method.invoke(Native Method)
11-09 16:03:19.691 1944 2248 W Conscrypt: com.google.android.gms.org.conscrypt.Platform.setSocketWriteTimeout(:com.google.android.gms@11743470:13)
11-09 16:03:19.710 1944 1944 I WearableService: Wearable Services stopping
11-09 16:03:19.837 1944 2248 W Conscrypt: Could not set socket write timeout:
11-09 16:03:19.838 1944 2248 W Conscrypt: java.lang.reflect.Method.invoke(Native Method)
11-09 16:03:19.838 1944 2248 W Conscrypt: com.google.android.gms.org.conscrypt.Platform.setSocketWriteTimeout(:com.google.android.gms@11743470:13)
11-09 16:03:28.206 5829 5886 W unknown:InspectorPackagerConnection: Couldn't connect to packager, will silently retry
11-09 16:03:39.339 3495 3533 W Finsky : [210] com.google.android.finsky.FinskyApp.i(1468): No account configured on this device.
11-09 16:03:39.341 3495 3533 I Finsky : [210] com.google.android.finsky.c.e.run(1151): Replicating app states via AMAS.
11-09 16:03:39.397 3495 3533 I Finsky : [210] com.google.android.finsky.c.c.a(311): Completed 0 account content syncs with 0 successful.
11-09 16:03:39.397 3495 3495 I Finsky : [1] com.google.android.finsky.services.j.a(149): Installation state replication succeeded.
....
11-09 16:09:47.871 1944 2714 W Conscrypt: Could not set socket write timeout:
11-09 16:09:47.872 1944 2714 W Conscrypt: java.lang.reflect.Method.invoke(Native Method)
11-09 16:09:47.872 1944 2714 W Conscrypt: com.google.android.gms.org.conscrypt.Platform.setSocketWriteTimeout(:com.google.android.gms@11743470:13)
11-09 16:09:48.034 1944 2714 W Conscrypt: Could not set socket write timeout:
11-09 16:09:48.034 1944 2714 W Conscrypt: java.lang.reflect.Method.invoke(Native Method)
11-09 16:09:48.036 1944 2714 W Conscrypt: com.google.android.gms.org.conscrypt.Platform.setSocketWriteTimeout(:com.google.android.gms@11743470:13)
11-09 16:09:48.193 1944 2714 W GLSUser : [AppCertManager] IOException while requesting key:
11-09 16:09:48.193 1944 2714 W GLSUser : java.io.IOException: Invalid device key response.
11-09 16:09:48.193 1944 2714 W GLSUser : at eyw.a(:com.google.android.gms@11743470:14)
11-09 16:09:48.193 1944 2714 W GLSUser : at eyw.a(:com.google.android.gms@11743470:65)
11-09 16:09:48.193 1944 2714 W GLSUser : at eyu.a(:com.google.android.gms@11743470:8)
11-09 16:09:48.193 1944 2714 W GLSUser : at eyq.a(:com.google.android.gms@11743470:1)
11-09 16:09:48.193 1944 2714 W GLSUser : at eyp.a(:com.google.android.gms@11743470:10)
11-09 16:09:48.193 1944 2714 W GLSUser : at com.google.android.gms.auth.account.be.legacy.AuthCronChimeraService.b(:com.google.android.gms@11743470:7)
11-09 16:09:48.193 1944 2714 W GLSUser : at edr.call(:com.google.android.gms@11743470:3)
11-09 16:09:48.193 1944 2714 W GLSUser : at java.util.concurrent.FutureTask.run(FutureTask.java:237)
11-09 16:09:48.193 1944 2714 W GLSUser : at mmu.run(:com.google.android.gms@11743470:26)
11-09 16:09:48.193 1944 2714 W GLSUser : at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
11-09 16:09:48.193 1944 2714 W GLSUser : at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
11-09 16:09:48.193 1944 2714 W GLSUser : at mse.run(:com.google.android.gms@11743470)
11-09 16:09:48.193 1944 2714 W GLSUser : at java.lang.Thread.run(Thread.java:761)
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Reactions: 13
- Comments: 31 (8 by maintainers)
Here’s the complete logcat output: https://pastebin.com/LGK4zhYC
@blumendorf made a repository to reproduce this problem: https://github.com/ewyso/react-native-detox-e-android
I’m running detox this way:
and it runs fine unless
react-native-device-info
is imported (uncomment App.js line 18).In my case problem was in
react-native-device-info
package. Whenreact-native-device-info
is imported this bug happens. I just stubbed import for test environment and it works again.@ghsdh3409 's answer fixed it for me.
I had to put:
androidTestImplementation 'org.mockito:mockito-android:2.7.22'
toapp/build.gradle
or for previous versions of gradle:androidTestCompile 'org.mockito:mockito-android:2.7.22'
These are imports:
And at the end, I have put @ghsdh3409 's code in
DetoxTest.java
fromandroidTest
directory.(For those lazy like me, so that you don’t have to look for your correct imports yourself 😃 )
My problem also is due to
react-native-device-info
. As this comment, they are still trying to figure out.I temporary fix it by stubbing
WebSettings.getDefaultUserAgent()
usingmockito-android
in my Detox test code.@skv-headless I’ve pinpointed the problem of
react-native-device-info
to this line in the native module:This line make detox hang forever. If I comment it out, the detox test runs fine. Any clues on what might be going on ? 🤔
Any update on this as @ilonashub . i am getting the same behaviour here. the app launches but gets stuck and no tests are performed. Everything works fine when i use the emulator. btw i already did
adb reverse tcp:8081 tcp:8081
The log that is displayed by
detox test -c android.emu.debug - --debug-synchronization 300 -l verbose
It took me a day to come to the same conclusion, but yea - it’s RNDeviceInfo. The second I remove it from mainApplication.java and the tests start on android.
doing @machour’s change also fixes the issue. Is this something that detox can go around or should we look for ways to fix this in RNDEviceInfo? I don’t see anything out of the ordinary that deviceInfo does. https://developer.android.com/reference/android/webkit/WebSettings
Thanks for the quick response! So I ran the build again and made sure that if I open the installed app on the emulator it runs properly.
When I ran
detox test -c android.emu.release --debug-synchronization 300
nothing changed… It looks like it’s not able to open the app when I ran the detox test.The output for
detox test --configuration android.emu.release --debug-synchronization 300 --loglevel verbose
:and after a few minutes I start to see mocha’s timeouts…