From @bisonhubert on Thu Dec 08 2016 14:46:34 GMT-0500 (EST)
## Description of the issue
I am trying to run UI tests on an Android emulator, but because the Ubuntu stack does not have a visual device installed, the UI tests cannot locate different elements to interact with.
Environment:
Ubuntu 16.04 stack
React Native 0.38.0
Appium 16.0
WD 1.0
Mocha 2.5.3
Potential Workarounds
Iâm currently trying to install a video device that will allow the emulator to run with a window. If you have an idea for a workaround I would be open to it as Iâm not sure this is necessarily an issue, but itâs definitely blocking my ability to run UI tests as a workflow step.
Copied from original issue: https://github.com/bitrise-io/build.issues/issues/27
From @viktorbenei on Fri Dec 09 2016 06:25:28 GMT-0500 (EST)
How do you create & boot the android emulator?
Do you use our Create Android emulator
and Start Android emulator
steps?
From @bisonhubert on Fri Dec 09 2016 13:24:27 GMT-0500 (EST)
Hi @viktorbenei, I do use the built-in steps. Iâve also experimented with creating my own using a script.
Here are the details for the create-android-emulator step:
- version 1.0.0
- step does not run if previous step fails
- name: test
- target: android-24
- options for âandroid create avdâ: default
- custom hardware profile content: default
And for the start-android-emulator step:
- version 1.1.0
- emulator to boot: $BITRISE_EMULATOR_NAME
- skin: 768x1280
- commandâs flags -no-boot-anim -no-audio -no-window
- sdk path: $ANDROID_HOME
I realize that starting the emulator with -no-window is probably why the UI tests arenât able to locate page objects (no window, no UI), but when I remove that flag, the âstart-android-emulator@1.1.0â step hangs for 13 minutes and eventually fails, so the appium driver isnât able to locate a connected device. The step hangs on the message SDL init failure, reason is: No available video device
.
Iâve also tried installing a video device with echo y | apt-get install ia32-libs-sdl
but this returns the same string as above.
From @viktorbenei on Fri Dec 09 2016 13:26:51 GMT-0500 (EST)
Thanks for the infos @bisonhubert !
The emulator should be able to boot without the -no-window
flag - weâll try to check this ASAP and let you know if we can find anything!
From @bisonhubert on Tue Dec 13 2016 15:28:34 GMT-0500 (EST)
Hi @viktorbenei @godrei,
Were either of you able to replicate the issue Iâm having getting the Android emulator to run without the -no-window flag?
From @viktorbenei on Tue Dec 13 2016 15:38:03 GMT-0500 (EST)
Sorry, we were a bit tight on schedule due to the new CLI release, but itâs scheduled as the first task for tomorrow!
From @godrei on Thu Dec 15 2016 11:07:33 GMT-0500 (EST)
Hi @bisonhubert ,
i validated, that on linux stacks, we can not run emulator without the -no-window
flag. It may happens because of the linux vms are prepared with server version of ubuntu, which does not contains desktop, so there are no windowsâŚ
Alternatively you can run your android builds on xamarin stacks (they contains tools, for both ios and android development), this stacks are prepared with osx.
Somehow i was not able to run emulator with android-24 platform, (android-23 was removed by google), but android-22 emulator starts correctly on xamarin stack.
We are working on to provide solution to run emulator on linux stack and figure out, what is the problem with android-24 + -no-window on xamarin stack.
From @bisonhubert on Thu Dec 15 2016 18:27:41 GMT-0500 (EST)
Hi @godrei
Thank you for getting back to me. I will be sure to try the Xamarin stacks to see if I can get the UI tests to run.
From @viktorbenei on Mon Dec 19 2016 09:58:08 GMT-0500 (EST)
@bisonhubert we found another possible workaround, although weâre still validating this:
Install the libqt5widgets5
package (e.g. with a Script step: sudo apt-get install -y libqt5widgets5
), before the first Emulator step, and also set the QT_QPA_PLATFORM
environment variable to offscreen
(you can set this as an App Env Var).
With this config we could successfully boot an android-21
emulator without the -no-window
flag, although there are a couple of warnings which could probably be fixed with other configs / packages (weâre still investigating).
If you have the time @bisonhubert itâd help a lot if you could test this with your project.
From @viktorbenei on Mon Dec 19 2016 09:58:28 GMT-0500 (EST)
On the Android/Ubuntu stack of course, not on the Xamarin stack
From @viktorbenei on Tue Dec 20 2016 03:30:51 GMT-0500 (EST)
The libqt5widgets5
package is now preinstalled on the Android/Ubuntu 16 stack, so only the environment variable have to be set. Once we confirm that this works properly in every case (including the window mode) weâll add the env var to the standard config/image too.
Please let us know @bisonhubert if you can validate it with your project!
From @bisonhubert on Tue Dec 20 2016 17:20:18 GMT-0500 (EST)
Hi @viktorbenei,
Thank you for the updates. Starting an Android emulator with the no-window
flag no longer hangs the build, and my first test is passing (!!!)
To set the QT_QPA_PLATFORM
environment variable within a script step, I had to set the key and value explicitly, as listed in the first example of the Expose an Environment Variable section of your documentation. Working with the pipe operator in the second example caused the start-emulator step to hang with the following error:
Starting emulator
/opt/android-sdk-linux/tools/emulator64-arm -avd test -skin 768x1280 -no-boot-anim -no-audio
emulator: WARNING: Classic qemu does not support SMP. The hw.cpu.ncore option from your config file is ignored.
This application failed to start because it could not find or load the Qt platform plugin "offscreen".
Available platform plugins are: linuxfb, minimal, offscreen, xcb.
Reinstalling the application may fix this problem.
I will be working now to optimize the speed of the testing workflow step, as the ARM abis are notoriously slow. Thank you for all your help.
From @viktorbenei on Wed Dec 21 2016 05:43:40 GMT-0500 (EST)
@bisonhubert thanks for the info!
We tested a couple of things and decided to set these environment variables by default, so, ideally, after this weekendâs stack update you wonât need to define anything, the emulator steps should âjust workâ, with or without the -no-window
flag.
Related PR: https://github.com/bitrise-docker/android/pull/49/files