无法在Docker容器中运行android模拟器

我试图运行Android模拟器来运行一些testing。 我有一个包含Android SDK的Docker容器,包含构build工具,平台工具等等。 我已经成功创build了AVD:

jenkins@b4c6c9cee181:/$ android list avd Available Android Virtual Devices: Name: hudson_de-DE_160_HVGA_android-24_armeabi-v7a Path: /home/jenkins/.android/avd/hudson_de-DE_160_HVGA_android-24_armeabi-v7a.avd Target: Android 7.0 (API level 24) Tag/ABI: default/armeabi-v7a Skin: hvga Sdcard: 200M Snapshot: true jenkins@b4c6c9cee181:/$ 

当我尝试启动一个模拟器时,显示如下:

 jenkins@b4c6c9cee181:/$ /usr/local/android-sdk-linux/tools/emulator -ports 5750,5751 -report-console tcp:5813,max=60 -prop persist.sys.language=de -prop persist.sys.country=DE -avd hudson_de-DE_160_HVGA_android-24_armeabi-v7a -no-snapshot-load -no-snapshot-save -no-window -noaudio -verbose emulator: found ANDROID_SDK_ROOT: /usr/local/android-sdk-linux emulator: Android virtual device file at: /home/jenkins/.android/avd/hudson_de-DE_160_HVGA_android-24_armeabi-v7a.ini emulator: virtual device content at /home/jenkins/.android/avd/hudson_de-DE_160_HVGA_android-24_armeabi-v7a.avd emulator: virtual device config file: /home/jenkins/.android/avd/hudson_de-DE_160_HVGA_android-24_armeabi-v7a.avd/config.ini emulator: using core hw config path: /home/jenkins/.android/avd/hudson_de-DE_160_HVGA_android-24_armeabi-v7a.avd/hardware-qemu.ini emulator: Found AVD target API level: 24 emulator: Read property file at /usr/local/android-sdk-linux/system-images/android-24/default/armeabi-v7a//build.prop emulator: No boot.prop property file found. emulator: found skin 'HVGA' in directory: /usr/local/android-sdk-linux/platforms/android-24/skins emulator: autoconfig: -skin HVGA emulator: autoconfig: -skindir /usr/local/android-sdk-linux/platforms/android-24/skins emulator: found skin-specific hardware.ini: /usr/local/android-sdk-linux/platforms/android-24/skins/HVGA/hardware.ini emulator: keyset loaded from: /home/jenkins/.android/default.keyset emulator: trying to load skin file '/usr/local/android-sdk-linux/platforms/android-24/skins/HVGA/layout' emulator: skin network speed: 'full' emulator: skin network delay: 'none' emulator: autoconfig: -kernel /usr/local/android-sdk-linux/system-images/android-24/default/armeabi-v7a//kernel-qemu emulator: Auto-detect: Kernel image requires legacy device naming scheme. emulator: Auto-detect: Kernel does not support YAFFS2 partitions. emulator: autoconfig: -ramdisk /usr/local/android-sdk-linux/system-images/android-24/default/armeabi-v7a//ramdisk.img emulator: Using initial system image: /usr/local/android-sdk-linux/system-images/android-24/default/armeabi-v7a//system.img emulator: autoconfig: -data /home/jenkins/.android/avd/hudson_de-DE_160_HVGA_android-24_armeabi-v7a.avd/userdata-qemu.img emulator: autoconfig: -initdata /home/jenkins/.android/avd/hudson_de-DE_160_HVGA_android-24_armeabi-v7a.avd/userdata.img emulator: autoconfig: -cache /home/jenkins/.android/avd/hudson_de-DE_160_HVGA_android-24_armeabi-v7a.avd/cache.img emulator: autoconfig: -sdcard /home/jenkins/.android/avd/hudson_de-DE_160_HVGA_android-24_armeabi-v7a.avd/sdcard.img emulator: WARNING: Increasing RAM size to 1GB emulator: Physical RAM size: 1024MB emulator: autoconfig: -snapstorage /home/jenkins/.android/avd/hudson_de-DE_160_HVGA_android-24_armeabi-v7a.avd/snapshots.img emulator: GPU emulation is disabled emulator: WARNING: CPU acceleration only works with x86/x86_64 system images. Content of hardware configuration file: hw.cpu.arch = arm hw.cpu.model = cortex-a8 hw.ramSize = 1024 hw.screen = touch hw.mainKeys = yes hw.trackBall = yes hw.keyboard = no hw.keyboard.lid = no hw.keyboard.charmap = qwerty2 hw.dPad = yes hw.gsmModem = yes hw.gps = yes hw.battery = yes hw.accelerometer = yes hw.audioInput = yes hw.audioOutput = yes hw.sdCard = yes hw.sdCard.path = /home/jenkins/.android/avd/hudson_de-DE_160_HVGA_android-24_armeabi-v7a.avd/sdcard.img disk.cachePartition = yes disk.cachePartition.path = /home/jenkins/.android/avd/hudson_de-DE_160_HVGA_android-24_armeabi-v7a.avd/cache.img disk.cachePartition.size = 66m hw.lcd.width = 320 hw.lcd.height = 480 hw.lcd.depth = 16 hw.lcd.density = 160 hw.lcd.backlight = yes hw.gpu.enabled = no hw.initialOrientation = portrait hw.camera.back = emulated hw.camera.front = none vm.heapSize = 48 hw.sensors.proximity = yes hw.sensors.magnetic_field = yes hw.sensors.orientation = yes hw.sensors.temperature = yes hw.useext4 = yes kernel.path = /usr/local/android-sdk-linux/system-images/android-24/default/armeabi-v7a//kernel-qemu kernel.parameters = androidboot.hardware=goldfish android.checkjni=1 kernel.newDeviceNaming = no kernel.supportsYaffs2 = no disk.ramdisk.path = /usr/local/android-sdk-linux/system-images/android-24/default/armeabi-v7a//ramdisk.img disk.systemPartition.initPath = /usr/local/android-sdk-linux/system-images/android-24/default/armeabi-v7a//system.img disk.systemPartition.size = 1792m disk.dataPartition.path = /home/jenkins/.android/avd/hudson_de-DE_160_HVGA_android-24_armeabi-v7a.avd/userdata-qemu.img disk.dataPartition.size = 550m disk.snapStorage.path = /home/jenkins/.android/avd/hudson_de-DE_160_HVGA_android-24_armeabi-v7a.avd/snapshots.img avd.name = hudson_de-DE_160_HVGA_android-24_armeabi-v7a . QEMU options list: emulator: argv[00] = "/usr/local/android-sdk-linux/tools/emulator" emulator: argv[01] = "-audio" emulator: argv[02] = "none" emulator: argv[03] = "-boot-property" emulator: argv[04] = "persist.sys.language=de" emulator: argv[05] = "-boot-property" emulator: argv[06] = "persist.sys.country=DE" emulator: argv[07] = "-android-ports" emulator: argv[08] = "5750,5751" emulator: argv[09] = "-android-report-console" emulator: argv[10] = "tcp:5813,max=60" emulator: argv[11] = "-android-hw" emulator: argv[12] = "/home/jenkins/.android/avd/hudson_de-DE_160_HVGA_android-24_armeabi-v7a.avd/hardware-qemu.ini" Concatenated QEMU options: /usr/local/android-sdk-linux/tools/emulator -audio none -boot-property persist.sys.language=de -boot-property persist.sys.country=DE -android-ports 5750,5751 -android-report-console tcp:5813,max=60 -android-hw /home/jenkins/.android/avd/hudson_de-DE_160_HVGA_android-24_armeabi-v7a.avd/hardware-qemu.ini emulator: Starting QEMU main loop emulator: trying to find: /usr/local/android-sdk-linux/tools/lib/ca-bundle.pem emulator: registered 'boot-properties' qemud service emulator: registered 'boot-properties' qemud service emulator: Adding boot property: 'persist.sys.language' = 'de' emulator: Adding boot property: 'persist.sys.country' = 'DE' emulator: Using kernel serial device prefix: ttyS emulator: Ramdisk image contains fstab.goldfish file emulator: Found format of system partition: 'ext4' emulator: Found format of userdata partition: 'ext4' emulator: Found format of cache partition: 'ext4' emulator: system partition format: ext4 emulator: Mapping 'system' partition image to /tmp/android-unknown/emulator-EwS9zv emulator: nand_add_dev: system,size=0x70000000,file=/tmp/android-unknown/emulator-EwS9zv,initfile=/usr/local/android-sdk-linux/system-images/android-24/default/armeabi-v7a//system.img,pagesize=512,extrasize=0 emulator: userdata partition format: ext4 emulator: nand_add_dev: userdata,size=0x22600000,file=/home/jenkins/.android/avd/hudson_de-DE_160_HVGA_android-24_armeabi-v7a.avd/userdata-qemu.img,pagesize=512,extrasize=0 emulator: cache partition format: ext4 emulator: nand_add_dev: cache,size=0x4200000,file=/home/jenkins/.android/avd/hudson_de-DE_160_HVGA_android-24_armeabi-v7a.avd/cache.img,pagesize=512,extrasize=0 emulator: Adding boot property: 'dalvik.vm.heapsize' = '48m' emulator: Adding boot property: 'qemu.sf.lcd_density' = '160' emulator: Adding boot property: 'qemu.hw.mainkeys' = '1' emulator: Adding boot property: 'qemu.sf.fake_camera' = 'back' emulator: Kernel parameters: qemu.gles=0 qemu=1 console=ttyS0 android.qemud=ttyS1 androidboot.hardware=goldfish android.checkjni=1 ndns=2 emulator: Forcing ro.adb.qemud to "0". emulator: trying to find console-report client on tcp:5813 emulator: trying to find console-report client on tcp:5813 emulator: trying to find console-report client on tcp:5813 emulator: trying to find console-report client on tcp:5813 emulator: trying to find console-report client on tcp:5813 emulator: trying to find console-report client on tcp:5813 emulator: trying to find console-report client on tcp:5813 emulator: trying to find console-report client on tcp:5813 emulator: trying to find console-report client on tcp:5813 emulator: trying to find console-report client on tcp:5813 emulator: trying to find console-report client on tcp:5813 emulator: trying to find console-report client on tcp:5813 emulator: trying to find console-report client on tcp:5813 emulator: trying to find console-report client on tcp:5813 emulator: trying to find console-report client on tcp:5813 emulator: trying to find console-report client on tcp:5813 emulator: trying to find console-report client on tcp:5813 emulator: trying to find console-report client on tcp:5813 emulator: trying to find console-report client on tcp:5813 emulator: trying to find console-report client on tcp:5813 emulator: trying to find console-report client on tcp:5813 emulator: trying to find console-report client on tcp:5813 emulator: trying to find console-report client on tcp:5813 emulator: trying to find console-report client on tcp:5813 emulator: trying to find console-report client on tcp:5813 emulator: trying to find console-report client on tcp:5813 emulator: trying to find console-report client on tcp:5813 emulator: trying to find console-report client on tcp:5813 emulator: trying to find console-report client on tcp:5813 emulator: trying to find console-report client on tcp:5813 emulator: trying to find console-report client on tcp:5813 emulator: trying to find console-report client on tcp:5813 emulator: trying to find console-report client on tcp:5813 emulator: trying to find console-report client on tcp:5813 emulator: trying to find console-report client on tcp:5813 emulator: trying to find console-report client on tcp:5813 emulator: trying to find console-report client on tcp:5813 emulator: trying to find console-report client on tcp:5813 emulator: trying to find console-report client on tcp:5813 emulator: trying to find console-report client on tcp:5813 emulator: trying to find console-report client on tcp:5813 emulator: trying to find console-report client on tcp:5813 emulator: trying to find console-report client on tcp:5813 emulator: trying to find console-report client on tcp:5813 emulator: trying to find console-report client on tcp:5813 emulator: trying to find console-report client on tcp:5813 emulator: trying to find console-report client on tcp:5813 emulator: trying to find console-report client on tcp:5813 emulator: trying to find console-report client on tcp:5813 emulator: trying to find console-report client on tcp:5813 emulator: trying to find console-report client on tcp:5813 emulator: trying to find console-report client on tcp:5813 emulator: trying to find console-report client on tcp:5813 emulator: trying to find console-report client on tcp:5813 emulator: trying to find console-report client on tcp:5813 emulator: trying to find console-report client on tcp:5813 emulator: trying to find console-report client on tcp:5813 emulator: trying to find console-report client on tcp:5813 emulator: trying to find console-report client on tcp:5813 emulator: trying to find console-report client on tcp:5813 could not connect to server on TCP:5813: Transport endpoint is not connected emulator: User-config was not changed. jenkins@b4c6c9cee181:/$ 

试图从命令行实现这一点,以便能够在Jenkinspipe道插件中运行它

谢谢你的帮助

更新:我正在运行模拟器arm

 jenkins@b4c6c9cee181:/$ ls -l /usr/local/android-sdk-linux/tools/emulator lrwxrwxrwx. 1 root root 47 Dec 22 15:38 /usr/local/android-sdk-linux/tools/emulator -> /usr/local/android-sdk-linux/tools/emulator-arm jenkins@b4c6c9cee181:/$ 

Interesting Posts