启动

时间:2017-04-30 12:00:25

标签: android ubuntu jenkins android-emulator

Jenkins无法运行Android模拟器。

[android] Using Android SDK: /opt/android-sdk-linux
[android] Creating Android AVD: /var/lib/jenkins/.android/avd/hudson_en-US_240_WVGA_android-23_google_apis-x86_64.avd
[android] /opt/android-sdk-linux/tools/android create avd -f -a -s WVGA800 -n hudson_en-US_240_WVGA_android-23_google_apis-x86_64 -t android-23 --abi google_apis/x86_64
$ /opt/android-sdk-linux/platform-tools/adb start-server

* daemon not running. starting it now at tcp:5837 *
* daemon started successfully *
$ /opt/android-sdk-linux/platform-tools/adb start-server
[android] Starting Android emulator
$ /opt/android-sdk-linux/tools/emulator -engine classic -ports 5682,5683 -report-console tcp:5827,max=60 -prop persist.sys.language=en -prop persist.sys.country=US -avd hudson_en-US_240_WVGA_android-23_google_apis-x86_64 -no-snapshot-load -no-snapshot-save -no-window
WARNING: Force to use classic engine to support snapshot.

[android] Emulator did not appear to start; giving up
[android] Stopping Android emulator
$ /opt/android-sdk-linux/platform-tools/adb kill-server
Finished: NOT_BUILT

然后,我尝试像jenkins一样运行模拟器。问题是android模拟器没有开始监听端口。首先,我使用'user'用户成功创建并启动了模拟器,如下所示:

user@host:~$android create avd -f -a -s WVGA800 -n test -t android-23 --abi google_apis/x86_64
Android 6.0 is a basic Android platform.
Do you wish to create a custom hardware profile [no]no
Created AVD 'test' based on Android 6.0, Google apis Intel Atom (x86_64) processor,
with the following hardware config:
hw.lcd.density=240
hw.ramSize=512
vm.heapSize=48
user@host:~$ emulator  -avd test -no-snapshot-load -no-snapshot-save -no-window
WARNING: Force to use classic engine to support snapshot.
emulator: WARNING: Classic qemu does not support SMP. The hw.cpu.ncore option from your config file is ignored.
Creating filesystem with parameters:
    Size: 69206016
    Block size: 4096
    Blocks per group: 32768
    Inodes per group: 4224
    Inode size: 256
    Journal blocks: 1024
    Label: 
    Blocks: 16896
    Block groups: 1
    Reserved block group size: 7
Created filesystem with 11/4224 inodes and 1302/16896 blocks
emulator: Listening for console connections on port: 5554
emulator: Serial number of this emulator (for ADB): emulator-5554
[139763360147200]:WARNING:./android/base/files/IniFile.cpp:158:Failed to process .ini file /home/user/.android/emu-update-last-check.ini for reading.
emulator: WARNING: UpdateCheck: Failure: No error
none.xml:1: parser error : Extra content at the end of the document
amp;uid=&amp;os=Linuxversion=25.2.5.0&amp;coreVersion=qemu1%200.10.50">Found</a>
                                                                               ^
emulator: WARNING: UpdateCheck: failed to get the latest version, skipping check (current version '25.2.5-3567187')

所以一切都与'用户'用户有关,但对于'jenkins'用户我有问题

jenkins@host:~$ android create avd -f -a -s WVGA800 -n test -t android-23 --abi google_apis/x86_64
Android 6.0 is a basic Android platform.
Do you wish to create a custom hardware profile [no]no
Created AVD 'test' based on Android 6.0, Google apis Intel Atom (x86_64) processor,
with the following hardware config:
hw.lcd.density=240
hw.ramSize=512
vm.heapSize=48
jenkins@host:~$ emulator  -avd test -no-snapshot-load -no-snapshot-save -no-window
WARNING: Force to use classic engine to support snapshot.
emulator: WARNING: Classic qemu does not support SMP. The hw.cpu.ncore option from your config file is ignored.
Creating filesystem with parameters:
    Size: 69206016
    Block size: 4096
    Blocks per group: 32768
    Inodes per group: 4224
    Inode size: 256
    Journal blocks: 1024
    Label: 
    Blocks: 16896
    Block groups: 1
    Reserved block group size: 7
Created filesystem with 11/4224 inodes and 1302/16896 blocks

就是这样!无论我多久等待“模拟器:在端口上侦听控制台连接:5554”都没有来!

BTW,kvm正在为两个用户运行

$ kvm-ok
INFO: /dev/kvm exists
KVM acceleration can be used

此外,“ANDROID_HOME”和“HOME”环境参数也是如此。

有什么建议吗?

更新

当我使用google_apis/armeabi-v7a abi时,我注意到这个问题没有发生。所以我认为这个问题与kvm安装有关,但我不知道如何修复它。

jenkins@hosst:~$ android create avd -f -a -s WVGA800 -n test -t android-23 --abi google_apis/armeabi-v7a
Android 6.0 is a basic Android platform.
Do you wish to create a custom hardware profile [no]no
Created AVD 'test' based on Android 6.0, Google apis ARM (armeabi-v7a) processor,
with the following hardware config:
hw.lcd.density=240
hw.ramSize=512
vm.heapSize=48
jenkins@host:~$ emulator -avd test -no-window
WARNING: Force to use classic engine to support snapshot.
emulator: WARNING: System image is writable
emulator: WARNING: Classic qemu does not support SMP. The hw.cpu.ncore option from your config file is ignored.
[140306725234432]:WARNING:./android/base/files/IniFile.cpp:158:Failed to process .ini file /var/lib/jenkins/.android/avd/test.avd/snapshots.img.default-boot.ini for reading.
Creating filesystem with parameters:
    Size: 69206016
    Block size: 4096
    Blocks per group: 32768
    Inodes per group: 4224
    Inode size: 256
    Journal blocks: 1024
    Label: 
    Blocks: 16896
    Block groups: 1
    Reserved block group size: 7
Created filesystem with 11/4224 inodes and 1302/16896 blocks
emulator: Listening for console connections on port: 5554
emulator: Serial number of this emulator (for ADB): emulator-5554
[140306725234432]:WARNING:./android/base/files/IniFile.cpp:158:Failed to process .ini file /var/lib/jenkins/.android/emu-update-last-check.ini for reading.
emulator: WARNING: UpdateCheck: Failure: No error
none.xml:1: parser error : Extra content at the end of the document
amp;uid=&amp;os=Linuxversion=25.2.5.0&amp;coreVersion=qemu1%200.10.50">Found</a>
                                                                               ^
emulator: WARNING: UpdateCheck: failed to get the latest version, skipping check (current version '25.2.5-3567187')

更新#2 在我成功运行模拟器并在下面发布我的答案后,我再次陷入这个问题!我的解决方案不再适用了:(顺便说一下,我发现了另一条线索,我想在这里与你分享。以下命令没有开始听我之前提到过的端口

android-sdk-linux/tools/emulator -avd test -no-snapshot-load -no-snapshot-save -no-window

但令人惊讶的是,这个命令正在运行okey

android-sdk-linux/tools/qemu/linux-x86_64/qemu-system-x86_64 -avd test -no-snapshot-load -no-snapshot-save -no-window

我想emulator应该运行qemu-system-x86_64,但在某处它会出错并运行emulator64-x86。在此发现之后的事件我无法弄清楚如何将此命令放在Android Emulator plugin中!所以问题再次开放。

1 个答案:

答案 0 :(得分:2)

从我的更新中我得到了一些线索,这个问题与kvm安装有关。我正在使用这个post来安装kvm。另一方面,我注意到user用户是libvirt组的成员,该组与kvm权限相关。所以我将jenkins用户添加到libvirt群组并发出爆炸声!问题解决了。

usermod -a -G libvirt jenkins