Travis CI Android模拟器网络

时间:2018-03-16 09:05:16

标签: android testing android-emulator travis-ci android-testing

我想在Travis CI上运行Android测试,但似乎模拟器没有连接到网络。 Travis CI的Android Emulator是否支持使用网络?如果是这样,如何配置.travis.yml来启用此功能?

我的应用使用Firebase云消息传递,它将在应用程序打开时检索令牌。我的Android测试是看看我的应用是否在应用程序打开后10秒成功获取令牌。我可以在本地通过测试但在Travis CI的模拟器上失败。这就是我怀疑模拟器无法连接到网络的原因。

我的.travis.yml是:

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 the 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

0 个答案:

没有答案