Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Detox android examples fail in Linux #1058

Closed
mmmguitar opened this issue Nov 28, 2018 · 8 comments
Closed

Detox android examples fail in Linux #1058

mmmguitar opened this issue Nov 28, 2018 · 8 comments

Comments

@mmmguitar
Copy link

mmmguitar commented Nov 28, 2018

Description

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.

Steps to Reproduce

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:

  1. Enter the example directory
  2. Type yarn to init all the dependencies
  3. Then either yarn test-android, yarn e2e or whatever script is set in the package.json to kick of the android tests.

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.

What went wrong

  1. 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.

  1. exmaples/demo-react-native:

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.

  1. exmaples/demo-react-native-jest:

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.

Detox, Node, Device, Xcode and macOS Versions

These are defined in the examples:

  • Detox: "detox": "^9.1.2"
  • React Native: "0.51.1"

These defined on my system:

  • Node: v8.14.0
  • Device: Pixel_API_26 on up to date android sdk / emulator

These are not applicable because I am on Linux:

  • Xcode:
  • macOS:

I'll add this one:

  • linux: Linux mint 18.2 (essentially just a recent Ubunut)

Device and verbose Detox logs

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.

@mmmguitar
Copy link
Author

mmmguitar commented Nov 28, 2018

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 mmmguitar changed the title Detox android examples fail Linux Detox android examples fail in Linux Nov 28, 2018
@pwfcurry
Copy link
Contributor

Related:
expo/detox-expo-helpers#2
#1017

@LeoNatan
Copy link
Contributor

LeoNatan commented Dec 1, 2018

@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.

@juddey
Copy link

juddey commented Dec 4, 2018

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.

@rotemmiz
Copy link
Member

rotemmiz commented Dec 4, 2018

Android E2E runs on Linux in CI @LeoNatan

@rotemmiz
Copy link
Member

rotemmiz commented Dec 4, 2018

Actually @noomorph works mostly on Linux when developing for Android

@noomorph
Copy link
Collaborator

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

@noomorph
Copy link
Collaborator

demo-react-native and demo-react-native-jest have been fixed on Linux+Android in 12.4.0.

@lock lock bot locked as resolved and limited conversation to collaborators Apr 21, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

7 participants