有没有办法在 Travis CI 构建中启动 android 模拟器?
Is there a way to start android emulator in Travis CI build?
我有 python wrapper-library for adb 我有依赖于模拟器或真实设备的单元测试(因为它们执行 adb 命令)。
我还想使用 Travis CI 作为构建环境,同时为每个构建执行这些单元测试。
有没有办法让 android 模拟器以某种方式在 Travis CI 中可用,以便单元测试可以执行 adb 命令?
提前致谢!
根据 Travis CI documentation,您可以在 .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
中指定您需要的系统映像即可。
B运行o Parmentier 的回答包括 Travis-CI 当前推荐的内容,但我遇到了 VM 运行ning 内存不足的问题。因此,我没有在构建 运行 宁时 运行 宁模拟器,而是将我的配置更改为 运行 构建,然后启动模拟器,然后 运行 测试。
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
我有 python wrapper-library for adb 我有依赖于模拟器或真实设备的单元测试(因为它们执行 adb 命令)。
我还想使用 Travis CI 作为构建环境,同时为每个构建执行这些单元测试。
有没有办法让 android 模拟器以某种方式在 Travis CI 中可用,以便单元测试可以执行 adb 命令?
提前致谢!
根据 Travis CI documentation,您可以在 .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
中指定您需要的系统映像即可。
B运行o Parmentier 的回答包括 Travis-CI 当前推荐的内容,但我遇到了 VM 运行ning 内存不足的问题。因此,我没有在构建 运行 宁时 运行 宁模拟器,而是将我的配置更改为 运行 构建,然后启动模拟器,然后 运行 测试。
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