I want to run e2e Detox tests in the Gitlab pipeline using an android emulator (using either the x86 or arm64 binaries). The pipeline fails in both cases either because the Gitlab runner does not support hardware virtualisation (x86) or because the Gitlab runner that uses the ARM environment does not play well with the reactnativecommunity/react-native-android
docker image in that job.
My conclusion is that there are two options, neither of which are simple. The options I think are available are described below. Is there a simpler solution?
-- Scenario with the x86 binary emulator ---
If I want to use the x86 binary, the pipeline needs to have hardware virtualisation support (as per the error logs).
ERROR | x86 emulation currently requires hardware acceleration!CPU acceleration status: KVM requires a CPU that supports vmx or svm
I've checked to see if I can install hardware virtualisation, via KVM, but KVM is not supported in the job. I ran the below script to check and it came back as 0 (not supported).
$ echo "Verify KVM support"Verify KVM support$ egrep -c '(vmx|svm)' /proc/cpuinfo0
This error persists even after turning off hardware virtualisation (-accel off, swiftshader_indirect).
$ANDROID_HOME/emulator/emulator -avd Pixel_5_API_30_x86 -no-boot-anim -no-snapshot -gpu -accel off swiftshader_indirect -memory 2048 -no-audio -no-window &
In this situation, it seems I have two options.
The first option is to use a third-party instance with KVM support inside the Gitlab pipeline. This would involve using an AWS instance that supports nested virtualization (e.g., m5d
, c5d
, or metal
instance types) and then installing and configuring KVM on that instance. I'd rather avoid this route, as it potentially seems complex and I'm not quite sure if it would still work with reactnativecommunity/react-native-android
docker image.
The second option is to use an ARM binary as this does not require hardware virtualisation.
-- Scenario with the ARM binary emulator ---
The trouble with using the ARM binary is that I need a Gitlab runner that also supports ARM but this does not work with the reactnativecommunity/react-native-android
docker image in that job.
This is part of the job in the .gitlab-ci.yml file:
android-test: stage: android-test image: reactnativecommunity/react-native-android:latest tags: - saas-linux-medium-arm64
The job fails:
ERROR: Job failed: failed to pull image "reactnativecommunity/react-native-android:latest" with specified policies [always]: no matching manifest for linux/arm64/v8 in the manifest list entries (manager.go:251:1s)
I looked into what exactly the reactnativecommunity/react-native-android
docker image provides and it includes a very handy set-up of install scripts, including: Android SDK, Node JS, JDK, Gradle, and React Native CLI.
It seems to me that the solution in this case would be remove the reactnativecommunity/react-native-android
docker image and instead, manually install all of the pre-requisites (i.e. Android SDK, Node JS, JDK, Gradle, and React Native CLI). However, that sounds pretty laborious.
--- My question:Is there a simpler and easier way of getting an android emulator to run either using x86 or arm64 binaries? I've searched the internet for answers and not much turns up matching the issue I have. Is it because most people do not use Gitlab and instead use Bitrise? Or do people just bite the bullet and use one of the two solutions above?