2个回答

7
根据Travis CI文档,您可以在.travis.yml中使用以下脚本启动模拟器:
# Emulator Management: Create, Start and Wait
before_script:
  - echo no | android create avd --force -n test -t android-19 --abi armeabi-v7a
  - emulator -avd test -no-skin -no-audio -no-window &
  - android-wait-for-emulator
  - adb shell input keyevent 82 &

只需在components中指定所需的系统镜像即可。

谢谢您的回答! - Viktor Malyi

5
sudo: false

language: android

env:
  global:
    # switch glibc to a memory conserving mode
    - MALLOC_ARENA_MAX=2
    # wait up to 10 minutes for adb to connect to emulator
    - ADB_INSTALL_TIMEOUT=10

android:
  components:
    - platform-tools
    - extra-android-m2repository
    - build-tools-22.0.1
    - android-22
    - sys-img-armeabi-v7a-android-22

script:
  - ./gradlew assemble lint

after_script:
  # Emulator Management: Create, Start and Wait
  - echo no | android create avd --force -n test -t android-22 --abi armeabi-v7a
  - emulator -avd test -no-skin -no-audio -no-window &
  - android-wait-for-emulator
  - adb shell input keyevent 82 &
  # now run the tests
  - ./gradlew connectedCheck

谢谢您的回答,但问题是关于如何启动模拟器,而不是如何管理内存消耗问题。 - Viktor Malyi
2
我在travis-ci上启动和可靠地运行模拟器时遇到了很多问题。以下是我必须采取的措施,以便以有用的方式实际运行模拟器。如果基本版本适用于您的工作,那就太幸运了 :) - Hans-Christoph Steiner
先生,我只想感谢您。您救了我的一天,我试了三天才弄清楚如何执行Espresso测试,当我几乎放弃时,您的after_script建议起了神奇的作用。 - Thomaz Freitas Barbosa

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接