vendredi 16 mars 2018

Network of Travis CI Android Emulator

I'd like to run a Android test on Travis CI, but seems like the emulator does not connect to network. Doest Travis CI's Android Emulator supports using network? If so, how to configure .travis.yml to enable this feature?

My app use Firebase Cloud Messaging, which will retrieve a token when the app is opened. My Android test is to see if my app successfully get the token 10 seconds after the app is opened. I can pass the test locally but fails when it's on Travis CI's emulator. That's why I suspect that the emulator cannot connect to network.

My .travis.yml is:

language: android
jdk: oraclejdk8
sudo: required # For faster internet speeds and more memory
android:
  components:
    - tools
    - tools

    # The BuildTools version used by your project
    - build-tools-26.0.2

    # The SDK version used to compile your project
    #- android-24
    - android-22

    # Specify at least one system image,
    # if you need to run emulator(s) during your tests
    - sys-img-armeabi-v7a-android-22

#https://docs.travis-ci.com/user/languages/android/#Caching
before_cache:
  - rm -f  $HOME/.gradle/caches/modules-2/modules-2.lock
  - rm -fr $HOME/.gradle/caches/*/plugin-resolution/
cache:
  directories:
    - $HOME/.gradle/caches/
    - $HOME/.gradle/wrapper/
- $HOME/.android/build-cache

before_script:
  - echo y | ${ANDROID_HOME}/tools/bin/sdkmanager --channel=3 "tools" "platform-tools" "build-tools;26.0.1" "platforms;android-26" "extras;google;m2repository"

  # Emulator Management: Create, Start and Wait
  - echo no | android create avd --force -n test -t android-22 --abi armeabi-v7a
  - emulator -avd test -no-audio -no-window &
  - android-wait-for-emulator
  - adb shell input keyevent 82 &

script: ./build.sh

Aucun commentaire:

Enregistrer un commentaire