2

I wanted to know if there was something specific to do to make Detox run in an emulator in Travis CI.

I'm working on a React Native project with Detox configured, and everything is working on my local machine (both iOS and Android). But every time I launch the Android job on the CI it fails... There is no problem with iOS which successfully run the test suite.

I tried different versions of the emulator and finally succeeded to have the emulator boot up (Android 22 and 28 for my tests), but now I always get the following errors that I can't seem to fix when launching the detox test command. The avdName name in the detox config file is the same as the one used to create the emulator in the CI so I don't understand the error and I can see in the logs that the emulator is ready...

detox[8418] ERROR: [exec.js/EXEC_FAIL, #1] ""/usr/local/android-sdk/tools/emulator" -version" failed with code = 1, stdout and stderr:

detox[8418] ERROR: [exec.js/EXEC_FAIL, #1] emulator: ERROR: No AVD specified. Use '@foo' or '-avd foo' to launch a virtual device named 'foo'

detox[8418] ERROR: [exec.js/EXEC_FAIL, #1] 

detox[8418] ERROR: [EmulatorVersionResolver.js/EMU_BIN_VERSION_DETECT] Could not detect emulator binary version { ChildProcessError: Command failed: "/usr/local/android-sdk/tools/emulator" -version

 `"/usr/local/android-sdk/tools/emulator" -version` (exited with error code 1)

    at callback (/home/travis/build/tsyirvo/react-native-starter/node_modules/child-process-promise/lib/index.js:33:27)

    at ChildProcess.exithandler (child_process.js:301:5)

    at ChildProcess.emit (events.js:198:13)

    at maybeClose (internal/child_process.js:982:16)

    at Process.ChildProcess._handle.onexit (internal/child_process.js:259:5)

  name: 'ChildProcessError',

  code: 1,

  childProcess:

   { ChildProcess: { [Function: ChildProcess] super_: [Function] },

     fork: [Function: fork],

     _forkChild: [Function: _forkChild],

     exec: [Function: exec],

     execFile: [Function: execFile],

     spawn: [Function: spawn],

     spawnSync: [Function: spawnSync],

     execFileSync: [Function: execFileSync],

     execSync: [Function: execSync] },

  stdout:

   'emulator: ERROR: No AVD specified. Use \'@foo\' or \'-avd foo\' to launch a virtual device named \'foo\'\n\n',

  stderr: '' }
detox[8418] WARN:  [EmulatorDriver.js/EMU_SKIN_CFG_PATCH] Failed to detect emulator version! (see previous logs)

This leaves Detox unable to tell if it should automatically apply this patch-fix: https://stackoverflow.com/a/47265664/453052, which seems to be needed in emulator versions < 28.

If you feel this is not needed, you can either ignore this message, or otherwise apply the patch manually.

detox[8418] ERROR: Error: No instrumentation runner found on device emulator-5554 for package com.rnstarter

My .travis.yml looks something like that:

env:
  global:
    - NODE_VERSION=10
    - ADB_INSTALL_TIMEOUT=8
    - ANDROID_HOME=/usr/local/android-sdk
    - ANDROID_SDK_ROOT=/usr/local/android-sdk
    - TOOLS=${ANDROID_HOME}/tools
    - PATH=${ANDROID_HOME}:${ANDROID_HOME}/emulator:${TOOLS}:${TOOLS}/bin:${ANDROID_HOME}/platform-tools:${PATH}

stages:
  - name: e2e_android

jobs:
  include:
    - stage: e2e_android
      language: android
      cache: npm
      android:
        components:
          - tools
          - platform-tools
          - tools
          - build-tools-28.0.3
          - android-28
          - extra-google-m2repository
          - extra-android-m2repository
          - sys-img-x86-android-28
      licenses:
        - 'android-sdk-license-.+'
        - 'android-sdk-preview-license-.+'
        - 'google-gdk-license-.+'
      before_install:
        - yes | sdkmanager "build-tools;28.0.3" >/dev/null 2>&1
        - yes | sdkmanager "platforms;android-28" >/dev/null 2>&1
      install:
        - wget https://raw.githubusercontent.com/creationix/nvm/v0.31.0/nvm.sh -O ~/.nvm/nvm.sh
        - source ~/.nvm/nvm.sh
        - nvm install $NODE_VERSION
        - nvm use $NODE_VERSION
        - nvm alias default $NODE_VERSION
        - npm install -g react-native-cli >/dev/null 2>&1
        - npm install -g detox-cli >/dev/null 2>&1
        - npm install >/dev/null 2>&1
      before_script:
        - echo no | android create avd --force -n test -t android-28 --abi default/x86
        - emulator -avd test -no-audio -no-window &
        # - android-wait-for-emulator
        - adb shell input keyevent 82 &
      script:
        - echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p
        - detox build -c android.emu.ci
        - detox test -c android.emu.ci -n test -H --cleanup

Did I miss something in the config ?

Thanks !

Tsyirvo
  • 86
  • 1
  • 9
  • Please take a closer look at the logs: This part -- `This leaves Detox unable to tell if it should automatically apply this patch-fix (...) If you feel this is not needed, you can either ignore this message, or otherwise apply the patch manually.` is just a warning. The real error is this: `detox[8418] ERROR: Error: No instrumentation runner found on device emulator-5554 for package com.rnstarter` – d4vidi Aug 18 '20 at 07:42
  • Have you properly set up a `DetoxTest.java` file on Android? Be sure to follow the setup guide step-by-step (long as it may be...) – d4vidi Aug 18 '20 at 07:44
  • Everything is correctly setup on the Detox side since I can run the tests without issues on my local machine. I'm going to take some time next week to investigate this issue further to see if I didn't miss something – Tsyirvo Aug 22 '20 at 14:21

0 Answers0