I'm trying to run the examples in the Detox git repo on a linux machine and I can't get a single one to work. Obviously the IOS ones arnt going to work given the lack of xcode and the IOS simulator + driver, but I thought the android ones should. Long story short, I'm trying to get an expo app I'm working on to run but failing, trying to simplify by running the examples first.
The examples are located in the root of the Detox git repository in the /examples directory, the ones I am trying to run are the android ones.
For exmaples/demo-native-android, exmaples/demo-react-native exmaples/demo-react-native-jest:
I've gone through setup the documentation, i.e. setting some global installs for detox and such. I can run an android emulator fine as well.
exmaples/demo-native-android:
I just get an error message:
1) "before all" hook:
TypeError: detox.config is not a function
Seems a striaght up detox issue, not sure how to fix / proceed.
First issue: There seems to be no script defined in the package.json to run the tests, I fixed this by copying over a similar line from the demo-react-native-jest to invoke the correct detox configuration.
After tweaking that the app builds, android starts, the app is installed and run but striaght into error.
Second issue: App starts to a red error screen: Unable to load script from asses 'index.android.bundle' Make sure your bundle is packaged correctly or you're running a packager server. CatalystInstaceImpl jniLoadScriptFromAssets.
Seems something to do with how the app is being started and react-native javascripts are being loaded. Again my knowledge of detox here is very small so unsure.
First issue: "pushd command not found"
Seems in the package.json there is a build command that assumes its being run in bash whereas I think on defult linux install its getting run in a default sh of some description. Either way, putting bash -lic 'build command' fixed that. Possible extraction here into a script with an appropriate shebang may help compatibility.
Second issue: The example android app doesnt build / dependency issues
> Configure project :app
WARNING: The specified Android SDK Build Tools version (27.0.2) is ignored, as it is below the minimum supported version (27.0.3) for Android Gradle Plugin 3.1.4.
Execution failed for task ':app:preDebugAndroidTestBuild'.
> Conflict with dependency 'com.android.support:support-annotations' in project ':app'. Resolved versions for app (27.0.2) and test app (27.1.1) differ. See https://d.android.com/r/tools/test-apk-dependency-conflicts.html for details.
I've tried to fix this but always ends in dependencies issues.
These are defined in the examples:
These defined on my system:
These are not applicable because I am on Linux:
I'll add this one:
For 2 exmaples/demo-react-native:
emulator: Android qemu version 28.0.16.0 (build_id 5112988) (CL:09d5defb2d25158a7e757ec46512f28e6d9656fd)
emulator: Starting QEMU main loop
emulator: registered 'boot-properties' qemud service
emulator: Adding boot property: 'ro.opengles.version' = '131072'
emulator: Adding boot property: 'qemu.sf.fake_camera' = 'both'
emulator: Adding boot property: 'dalvik.vm.heapsize' = '384m'
emulator: Adding boot property: 'qemu.hw.mainkeys' = '0'
emulator: Adding boot property: 'qemu.sf.lcd_density' = '480'
emulator: goldfish_events.have-dpad: false
emulator: goldfish_events.have-trackball: false
emulator: goldfish_events.have-camera: true
emulator: goldfish_events.have-keyboard: true
emulator: goldfish_events.have-lidswitch: false
emulator: goldfish_events.have-tabletmode: false
emulator: goldfish_events.have-touch: false
emulator: goldfish_events.have-multitouch: true
emulator: control console listening on port 5554, ADB on port 5555
VERBOSE: AdbHostServer.cpp:49: Send [0012host:emulator:5555] to adb daemon.
Not using any http proxy
emulator: Adding boot property: 'qemu.timezone' = 'Europe/London'
emulator: android_hw_fingerprint_init: fingerprint qemud listen service initialized
emulator: found skin 'pixel' in directory: /home/rtreveth/Android/Sdk/skins/
emulator: found skin 'pixel' in directory: /home/rtreveth/Android/Sdk/skins/
emulator: No acpi ini file provided, using default
emulator: Adding boot property: 'ro.opengles.version' = '131072'
emulator: Adding boot property: 'qemu.sf.fake_camera' = 'both'
emulator: Adding boot property: 'dalvik.vm.heapsize' = '384m'
emulator: Adding boot property: 'qemu.hw.mainkeys' = '0'
emulator: Adding boot property: 'qemu.sf.lcd_density' = '480'
emulator: Adding boot property: 'qemu.timezone' = 'Europe/London'
emulator: _hwFingerprint_connect: connect finger print listen is called
VERBOSE: AdbHostServer.cpp:49: Send [0012host:emulator:5555] to adb daemon.
emulator: onGuestSendCommand: [0x61a8960] Adb connected, start proxing data
VERBOSE: AdbHostServer.cpp:49: Send [0012host:emulator:5555] to adb daemon.
detox[29867] DEBUG: [exec.js/EXEC_CMD, #2] /home/rtreveth/Android/Sdk/platform-tools/adb devices
detox[29867] DEBUG: [exec.js/EXEC_CMD, #3] /home/rtreveth/Android/Sdk/platform-tools/adb -s emulator-5554 shell "getprop dev.bootcomplete"
detox[29867] DEBUG: [exec.js/EXEC_CMD, #4] /home/rtreveth/Android/Sdk/platform-tools/adb -s emulator-5554 shell "getprop ro.build.version.sdk"
detox[29867] DEBUG: [exec.js/EXEC_CMD, #5] /home/rtreveth/Android/Sdk/platform-tools/adb -s emulator-5554 shell "dumpsys power | grep \"^[ ]*m[UW].*=\""
detox[29867] DEBUG: [exec.js/EXEC_CMD, #6] /home/rtreveth/Android/Sdk/build-tools/28.0.3/aapt dump badging "/home/rtreveth/temp/Detox/examples/demo-react-native/android/app/build/outputs/apk/debug/app-debug.apk" | grep -e "package: name="
detox[29867] DEBUG: [exec.js/EXEC_CMD, #7] /home/rtreveth/Android/Sdk/platform-tools/adb -s emulator-5554 shell "pm list packages com.detox.rn.example"
detox[29867] DEBUG: [exec.js/EXEC_CMD, #8] /home/rtreveth/Android/Sdk/platform-tools/adb -s emulator-5554 uninstall com.detox.rn.example
detox[29867] DEBUG: [exec.js/EXEC_CMD, #9] /home/rtreveth/Android/Sdk/platform-tools/adb -s emulator-5554 shell "pm list packages com.detox.rn.example.test"
detox[29867] DEBUG: [exec.js/EXEC_CMD, #10] /home/rtreveth/Android/Sdk/platform-tools/adb -s emulator-5554 uninstall com.detox.rn.example.test
detox[29867] DEBUG: [exec.js/EXEC_CMD, #11] /home/rtreveth/Android/Sdk/platform-tools/adb -s emulator-5554 install -r -g /home/rtreveth/temp/Detox/examples/demo-react-native/android/app/build/outputs/apk/debug/app-debug.apk
detox[29867] DEBUG: [exec.js/EXEC_CMD, #12] /home/rtreveth/Android/Sdk/platform-tools/adb -s emulator-5554 install -r -g /home/rtreveth/temp/Detox/examples/demo-react-native/android/app/build/outputs/apk/androidTest/debug/app-debug-androidTest.apk
detox[29867] DEBUG: [exec.js/EXEC_CMD, #13] /home/rtreveth/Android/Sdk/platform-tools/adb -s emulator-5554 shell "am force-stop com.detox.rn.example"
detox[29867] DEBUG: [exec.js/EXEC_CMD, #14] /home/rtreveth/Android/Sdk/platform-tools/adb -s emulator-5554 shell "pm list instrumentation"
detox[29867] DEBUG: [exec.js/SPAWN_CMD, #15] [pid=30015] /home/rtreveth/Android/Sdk/platform-tools/adb -s emulator-5554 shell am instrument -w -r "-e detoxServer ws://localhost:43285 -e detoxSessionId 8ed3835d-cb35-8cd8-f46c-d4ebeff56dd8" -e debug false com.detox.rn.example.test/android.support.test.runner.AndroidJUnitRunner
detox[29867] DEBUG: [exec.js/EXEC_CMD, #16] /home/rtreveth/Android/Sdk/platform-tools/adb -s emulator-5554 shell "ps | grep \"com\.detox\.rn\.example$\""
detox[29867] DEBUG: [DetoxServer.js/CANNOT_FORWARD] role=testee not connected, cannot fw action (sessionId=8ed3835d-cb35-8cd8-f46c-d4ebeff56dd8)
I can past the QEMU options list if that is helpful, it should be default / standard. Thelast line of thes logs looks interesting but unsure what the root cause could be.
I'm trying to figure some of these out but new to Android / IOS dev and at a point where I think a little guiding could help alot.
As far as I am aware Detox doesnt officially support Android, and I suspect by reading over some of the code its been primirally developed on a Mac for IOS and expanded out to Android so I'm, unsure if linux is officially supported. I know IOS stuff will never work on Linux but I thought it should be possible with android and I see some people seem to be having success with it, any tricks? I'm happy to take a look at some of the issues / linux + android but some guidance would help alot.
@mmmguitar Small correction, we do support Android, we don't officially support Linux. The Linux support effort has been community-driven, and we are happy to help, but we do not have the resources to maintain Linux or Windows solely by ourselves.
Just a note for those that google later, I've managed to get Detox working on Android with RN 0.57.4 and React Native Navigation v2 on elementary OS 0.4.1 (thats a debian flavour of linux so should work with ubuntu as well)
Aiming to do an update of setup instructions but in the meantime feel free to @mention me.
Android E2E runs on Linux in CI @LeoNatan
Actually @noomorph works mostly on Linux when developing for Android
Guys, I think we might want to check if things really work there. The projects in examples are not being tested on Jenkins+Linux+Android, we have only detox-demo-projects which targets MacOS.
So, our issue reporters might be right that there's an issue with those example projects.
Personally, I could not run examples/demo-react-native-jest on Android.
Fixes are ongoing in branch: https://github.com/wix/Detox/tree/noomorph/fix/demo-react-native-jest
demo-react-native and demo-react-native-jest have been fixed on Linux+Android in 12.4.0.
Most helpful comment
@mmmguitar Small correction, we do support Android, we don't officially support Linux. The Linux support effort has been community-driven, and we are happy to help, but we do not have the resources to maintain Linux or Windows solely by ourselves.