在Travis CI中启动Android x86仿真器时出错

时间:2022-08-27 18:54:32

When I run

当我运行

android connectedCheck

with an ARM emulator in Travis, the build usually ends on a Timeout error. So I instead am trying to run my build and tests with the x86 emulator. But when I run the command:

在Travis中使用ARM模拟器,构建通常以超时错误结束。因此,我正在尝试使用x86仿真器运行我的构建和测试。但是当我运行命令时:

emulator -avd test -no-skin -no-audio -no-window &

I get this error:

我得到这个错误:

emulator: ERROR: x86 emulation currently requires hardware acceleration!
Please ensure KVM is properly installed and usable.
CPU acceleration status: KVM is not installed on this machine (/dev/kvm is missing).

I've noticed in the Travis CI docs that there does appear to be support for the x86 emulators, so I am asumming that it is possible. But I have been unable to find any reference to getting them to work properly with hardware acceleration. I have also tried running this command:

我在Travis CI文档中注意到,似乎确实支持x86仿真器,所以我确信这是可能的。但我一直找不到任何参考,以使它们在硬件加速的情况下正常工作。我还尝试运行这个命令:

sudo apt-get install qemu-kvm libvirt-bin ubuntu-vm-builder bridge-utils

before creating the emulator but I still get the same error.

在创建仿真器之前,我仍然会得到相同的错误。

Here is my .travis.yml script:

这是我的.travis。yml脚本:

language: android
jdk: oraclejdk7

env:
  global:
    - ANDROID_BUILD_API_LEVEL=22
    - ANDROID_BUILD_TOOLS_VERSION=22.0.1
    - ANDROID_ABI=default/x86
    - ANDROID_EMULATOR_API_LEVEL=19

android:
  components:
    #- platform-tools
    #- tools
    - build-tools-$ANDROID_BUILD_TOOLS_VERSION
    - android-$ANDROID_BUILD_API_LEVEL
    - android-$ANDROID_EMULATOR_API_LEVEL

    - addon-google_apis_x86-google-$ANDROID_EMULATOR_API_LEVEL

    - extra-google-google_play_services
    - extra-android-support
    - extra-google-m2repository
    - extra-android-m2repository

    - sys-img-x86-android-$ANDROID_EMULATOR_API_LEVEL

notifications:
  email: true

before_script:
  - sudo apt-get update -qq
  - sudo apt-get install -qq libstdc++6:i386 lib32z1 expect
  # for gradle output style
  - export TERM=dumb

  # environment info
  - ./gradlew -v
  - uname -a

  # emulator
  - echo no | android create avd --force -n test -t "Google Inc.:Google APIs (x86 System Image):"$ANDROID_EMULATOR_API_LEVEL --abi $ANDROID_ABI
  - emulator -avd test -no-skin -no-audio -no-window &
  - android-wait-for-emulator
  - adb shell input keyevent 82 &

# build
script:
  - ./gradlew clean connectedCheck -PdisablePreDex

Has anyone got this to work before?

有人用过这个吗?

1 个解决方案

#1


6  

Intel emulators cannot be run on Travis yet. Since Travis runs virtual machines, hardware acceleration in virtual machine in an other virtual machine is a hard thing.

英特尔模拟器还不能在Travis上运行。由于Travis运行的是虚拟机,因此在其他虚拟机中对虚拟机进行硬件加速是一件困难的事情。

You have to run ARM emulators for now.

你现在必须运行ARM模拟器。

They may do it in a near future. Subscribe to this issue to be notified. https://github.com/travis-ci/travis-ci/issues/1419

他们可能在不久的将来做这件事。订阅这个问题将被通知。https://github.com/travis-ci/travis-ci/issues/1419

#1


6  

Intel emulators cannot be run on Travis yet. Since Travis runs virtual machines, hardware acceleration in virtual machine in an other virtual machine is a hard thing.

英特尔模拟器还不能在Travis上运行。由于Travis运行的是虚拟机,因此在其他虚拟机中对虚拟机进行硬件加速是一件困难的事情。

You have to run ARM emulators for now.

你现在必须运行ARM模拟器。

They may do it in a near future. Subscribe to this issue to be notified. https://github.com/travis-ci/travis-ci/issues/1419

他们可能在不久的将来做这件事。订阅这个问题将被通知。https://github.com/travis-ci/travis-ci/issues/1419