带有vnc服务器的无头仿真器 [英] emulator-headless with vnc server

查看:271
本文介绍了带有vnc服务器的无头仿真器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图弄清楚如何通过远程服务器上的vnc使用android仿真器. 我在图形环境的ubuntu上安装了ightvnc服务器并启动它:

I am trying to figure out how to use android emulator via vnc on a remote server. I installed tightvnc server on ubuntu, graphic environment and started it:

apt install tightvnc
apt install xfonts-base
sudo apt-get install gnome-core xfce4 firefox nano -y --force-yes
vncpasswd
vncserver :2 -geometry 1080x1920 -depth 24

现在,我可以在5902端口上成功连接到服务器,并查看gui.

Now I can successfully connect to my server on 5902 port and see the gui.

现在,我正在尝试使用Android Pie启动模拟器:

Now I am trying to start the emulator with Android Pie:

echo 'no' | avdmanager create avd --force --name android-28-x86 --abi google_apis_playstore/x86 --package 'system-images;android-28;google_apis_playstore;x86'loop
export DISPLAY=2
emulator-headless @android-28-x86 -verbose -gpu swiftshader_indirect -no-audio -no-snapshot -qemu

没有成功.在VNC中看不到任何输出. 我在终端输出中看到以下内容:

No success. Can't see any output in the VNC. I see the following in the terminal output:

emulator: autoconfig: -skin HVGA
emulator: autoconfig: -skindir (null)
emulator: autoconfig: -kernel /root/android-sdk/system-images/android-28/google_apis_playstore/x86//kernel-ranchu-64
emulator: Target arch = 'x86'
emulator: Auto-config: -qemu -cpu qemu32
emulator: Auto-detect: Kernel image requires new device naming scheme.
emulator: Auto-detect: Kernel does not support YAFFS2 partitions.
emulator: autoconfig: -ramdisk /root/android-sdk/system-images/android-28/google_apis_playstore/x86//ramdisk.img
emulator: Using initial system image: /root/android-sdk/system-images/android-28/google_apis_playstore/x86//system.img
emulator: Using initial vendor image: /root/android-sdk/system-images/android-28/google_apis_playstore/x86//vendor.img
emulator: autoconfig: -data /root/.android/avd/android-28-x86.avd/userdata-qemu.img
emulator: autoconfig: -initdata /root/.android/avd/android-28-x86.avd/userdata.img
emulator: autoconfig: -cache /root/.android/avd/android-28-x86.avd/cache.img                          emulator: Increasing RAM size to 1536MB
emulator: VM heap size 0MB is below hardware specified minimum of 192MB,setting it to that value
emulator: System image is read only
emulator: Found 1 DNS servers: 127.0.0.53
emulator: skin name 'HVGA' aliased to '320x480'
emulator: found magic skin width=320 height=480 bpp=16

emulator: registered 'boot-properties' qemud service
emulator: Adding boot property: 'qemu.cmdline' = 'androidboot.logcat=v:* androidboot.consolepipe=qemu_pipe,pipe:logcat'
emulator: Adding boot property: 'qemu.logcat' = 'start'
emulator: CPU Acceleration: working
emulator: CPU Acceleration status: KVM (version 12) is installed and usable.
emulator: VERBOSE: AdbInterface.cpp:232: Found: 3 adb executables
emulator: VERBOSE: AdbInterface.cpp:234: Adb: /root/android-sdk/platform-tools/adb
emulator: VERBOSE: AdbInterface.cpp:234: Adb: /root/android-sdk/platform-tools/adb
emulator: VERBOSE: AdbInterface.cpp:234: Adb: /root/android-sdk/platform-tools/adb
emulator: VERBOSE: AdbInterface.cpp:253: Path:/root/android-sdk/platform-tools/adb protocol version: 41
emulator: VERBOSE: AdbInterface.cpp:253: Path:/root/android-sdk/platform-tools/adb protocol version: 41
emulator: VERBOSE: AdbInterface.cpp:253: Path:/root/android-sdk/platform-tools/adb protocol version: 41
emulator: GPU emulation enabled using 'swiftshader_indirect' mode
emulator: Initializing hardware OpenGLES emulation support
emulator: Found 1 DNS servers: 127.0.0.53
Content of hardware configuration file:
  hw.cpu.arch = x86
  hw.cpu.model = qemu32
  hw.cpu.ncore = 2
  hw.ramSize = 1536
  hw.screen = multi-touch
  hw.mainKeys = true
  hw.trackBall = true
  hw.keyboard = false
  hw.keyboard.lid = false
  hw.keyboard.charmap = qwerty2
  hw.dPad = true
  hw.rotaryInput = false
  hw.gsmModem = true
  hw.gps = true
  hw.battery = true
  hw.accelerometer = true
  hw.gyroscope = true
  hw.audioInput = true
  hw.audioOutput = true
  hw.sdCard = true
  disk.cachePartition = true
  disk.cachePartition.path = /root/.android/avd/android-28-x86.avd/cache.img
  disk.cachePartition.size = 66m
  test.quitAfterBootTimeOut = -1
  test.delayAdbTillBootComplete = 0
  test.monitorAdb = 0
  hw.lcd.width = 320
  hw.lcd.height = 480
  hw.lcd.depth = 16
  hw.lcd.density = 160
  hw.lcd.backlight = true
  hw.displayRegion.0.1.xOffset = -1
  hw.displayRegion.0.1.yOffset = -1
  hw.displayRegion.0.1.width = 0
  hw.displayRegion.0.1.height = 0
  hw.fold.adjust = false
  hw.gpu.enabled = true
  hw.gpu.mode = swiftshader_indirect
  hw.initialOrientation = portrait
  hw.camera.back = emulated
  hw.camera.front = none
  vm.heapSize = 192
  hw.sensors.light = true
  hw.sensors.pressure = true
  hw.sensors.humidity = true
  hw.sensors.proximity = true
  hw.sensors.magnetic_field = true
  hw.sensors.magnetic_field_uncalibrated = true
  hw.sensors.gyroscope_uncalibrated = true
  hw.sensors.orientation = true
  hw.sensors.temperature = true
  hw.useext4 = true
  hw.arc = false
  hw.arc.autologin = false
  kernel.path = /root/android-sdk/system-images/android-28/google_apis_playstore/x86//kernel-ranchu-64  kernel.newDeviceNaming = yes
  kernel.supportsYaffs2 = no
  disk.ramdisk.path = /root/android-sdk/system-images/android-28/google_apis_playstore/x86//ramdisk.img
  disk.systemPartition.initPath = /root/android-sdk/system-images/android-28/google_apis_playstore/x86//system.img
  disk.systemPartition.size = 2641m
  disk.vendorPartition.initPath = /root/android-sdk/system-images/android-28/google_apis_playstore/x86//vendor.img
  disk.vendorPartition.size = 800m
  disk.dataPartition.path = /root/.android/avd/android-28-x86.avd/userdata-qemu.img
  disk.dataPartition.size = 6g
  disk.encryptionKeyPartition.path = /root/.android/avd/android-28-x86.avd/encryptionkey.img
  PlayStore.enabled = false
  avd.name = android-28-x86
  fastboot.forceColdBoot = false
.
QEMU options list:
emulator: argv[00] = "/root/android-sdk/emulator/qemu/linux-x86_64/qemu-system-x86_64-headless"
emulator: argv[01] = "-dns-server"
emulator: argv[02] = "127.0.0.53"
emulator: argv[03] = "-no-audio"
emulator: argv[04] = "-serial"
emulator: argv[05] = "null"
emulator: argv[06] = "-device"
emulator: argv[07] = "goldfish_pstore,addr=0xff018000,size=0x10000,file=/root/.android/avd/android-28-x86.avd/data/misc/pstore/pstore.bin"
emulator: argv[08] = "-cpu"
emulator: argv[09] = "android64"
emulator: argv[10] = "-enable-kvm"
emulator: argv[11] = "-smp"
emulator: argv[12] = "cores=2"
emulator: argv[13] = "-m"
emulator: argv[14] = "1536"
emulator: argv[15] = "-lcd-density"
emulator: argv[16] = "160"
emulator: argv[17] = "-object"
emulator: argv[18] = "iothread,id=disk-iothread"
emulator: argv[19] = "-nodefaults"
emulator: argv[20] = "-kernel"
emulator: argv[21] = "/root/android-sdk/system-images/android-28/google_apis_playstore/x86//kernel-ranchu-64"
emulator: argv[22] = "-initrd"
emulator: argv[23] = "/root/android-sdk/system-images/android-28/google_apis_playstore/x86//ramdisk.img"
emulator: argv[24] = "-drive"
emulator: argv[25] = "if=none,index=0,id=system,file=/root/android-sdk/system-images/android-28/google_apis_playstore/x86//system.img,read-only"
emulator: argv[26] = "-device"
emulator: argv[27] = "virtio-blk-pci,drive=system,iothread=disk-iothread,modern-pio-notify"
emulator: argv[28] = "-drive"
emulator: argv[29] = "if=none,index=1,id=cache,file=/root/.android/avd/android-28-x86.avd/cache.img.qcow2,overlap-check=none,cache=unsafe,l2-cache-size=1048576"
emulator: argv[30] = "-device"
emulator: argv[31] = "virtio-blk-pci,drive=cache,iothread=disk-iothread,modern-pio-notify"
emulator: argv[32] = "-drive"
emulator: argv[33] = "if=none,index=2,id=userdata,file=/root/.android/avd/android-28-x86.avd/userdata-qemu.img.qcow2,overlap-check=none,cache=unsafe,l2-cache-size=1048576"
emulator: argv[34] = "-device"
emulator: argv[35] = "virtio-blk-pci,drive=userdata,iothread=disk-iothread,modern-pio-notify"
emulator: argv[36] = "-drive"
emulator: argv[37] = "if=none,index=3,id=encrypt,file=/root/.android/avd/android-28-x86.avd/encryptionkey.img.qcow2,overlap-check=none,cache=unsafe,l2-cache-size=1048576"
emulator: argv[38] = "-device"
emulator: argv[39] = "virtio-blk-pci,drive=encrypt,iothread=disk-iothread,modern-pio-notify"
emulator: argv[40] = "-drive"
emulator: argv[41] = "if=none,index=4,id=vendor,file=/root/android-sdk/system-images/android-28/google_apis_playstore/x86//vendor.img,read-only"
emulator: argv[42] = "-device"
emulator: argv[43] = "virtio-blk-pci,drive=vendor,iothread=disk-iothread,modern-pio-notify"
emulator: argv[44] = "-netdev"
emulator: argv[45] = "user,id=mynet"
emulator: argv[46] = "-device"
emulator: argv[47] = "virtio-net-pci,netdev=mynet"
emulator: argv[48] = "-device"
emulator: argv[49] = "virtio-rng-pci"
emulator: argv[50] = "-show-cursor"
emulator: argv[51] = "-L"
emulator: argv[52] = "/root/android-sdk/emulator/lib/pc-bios"
emulator: argv[53] = "-soundhw"
emulator: argv[54] = "hda"
emulator: argv[55] = "-vga"
emulator: argv[56] = "none"
emulator: argv[57] = "-append"
emulator: argv[58] = "qemu=1 no_timer_check androidboot.hardware=ranchu androidboot.serialno=EMULATOR29X0X11X0 clocksource=pit no-kvmclock android.qemud=1 console=0 android.checkjni=1 qemu.gles=1 qemu.settings.system.screen_off_timeout=2147483647 qemu.encrypt=1 qemu.opengles.version=131072 cma=260M@0-4G qemu.wifi=1 mac80211_hwsim.channels=2 androidboot.android_dt_dir=/sys/bus/platform/devices/ANDR0001:00/properties/android/ skip_initramfs rootwait ro init=/init loop.max_part=7 dm="1 vroot none ro 1,0 5159992 verity 1 PARTUUID=19E87A23-1C27-4616-8116-0088D1F64FD2 PARTUUID=19E87A23-1C27-4616-8116-0088D1F64FD2 4096 4096 644999 644999 sha1 3d4097abf29343cf6b86b9d6703c131e82429f69 5f81fddb8cc753b134fc2901766e57a49cfae566dba7ca48630fdddc30913f84 1 ignore_zero_blocks" androidboot.veritymode=enforcing androidboot.verifiedbootstate=orange root=/dev/dm-0 ramoops.mem_address=0xff018000 ramoops.mem_size=0x10000 memmap=0x10000$0xff018000 qemu.dalvik.vm.heapsize=192m"
emulator: argv[59] = "-android-hw"
emulator: argv[60] = "/root/.android/avd/android-28-x86.avd/hardware-qemu.ini"
Concatenated QEMU options:
 /root/android-sdk/emulator/qemu/linux-x86_64/qemu-system-x86_64-headless -dns-server 127.0.0.53 -no-audio -serial null -device goldfish_pstore,addr=0xff018000,size=0x10000,file=/root/.android/avd/android-28-x86.avd/data/misc/pstore/pstore.bin -cpu android64 -enable-kvm -smp cores=2 -m 1536 -lcd-density 160 -object iothread,id=disk-iothread -nodefaults -kernel /root/android-sdk/system-images/android-28/google_apis_playstore/x86//kernel-ranchu-64 -initrd /root/android-sdk/system-images/android-28/google_apis_playstore/x86//ramdisk.img -drive if=none,index=0,id=system,file=/root/android-sdk/system-images/android-28/google_apis_playstore/x86//system.img,read-only -device virtio-blk-pci,drive=system,iothread=disk-iothread,modern-pio-notify -drive if=none,index=1,id=cache,file=/root/.android/avd/android-28-x86.avd/cache.img.qcow2,overlap-check=none,cache=unsafe,l2-cache-size=1048576 -device virtio-blk-pci,drive=cache,iothread=disk-iothread,modern-pio-notify -drive if=none,index=2,id=userdata,file=/root/.android/avd/android-28-x86.avd/userdata-qemu.img.qcow2,overlap-check=none,cache=unsafe,l2-cache-size=1048576 -device virtio-blk-pci,drive=userdata,iothread=disk-iothread,modern-pio-notify -drive if=none,index=3,id=encrypt,file=/root/.android/avd/android-28-x86.avd/encryptionkey.img.qcow2,overlap-check=none,cache=unsafe,l2-cache-size=1048576 -device virtio-blk-pci,drive=encrypt,iothread=disk-iothread,modern-pio-notify -drive if=none,index=4,id=vendor,file=/root/android-sdk/system-images/android-28/google_apis_playstore/x86//vendor.img,read-only -device virtio-blk-pci,drive=vendor,iothread=disk-iothread,modern-pio-notify -netdev user,id=mynet -device virtio-net-pci,netdev=mynet -device virtio-rng-pci -show-cursor -L /root/android-sdk/emulator/lib/pc-bios -soundhw hda -vga none -append 'qemu=1 no_timer_check androidboot.hardware=ranchu androidboot.serialno=EMULATOR29X0X11X0 clocksource=pit no-kvmclock android.qemud=1 console=0 android.checkjni=1 qemu.gles=1 qemu.settings.system.screen_off_timeout=2147483647 qemu.encrypt=1 qemu.opengles.version=131072 cma=260M@0-4G qemu.wifi=1 mac80211_hwsim.channels=2 androidboot.android_dt_dir=/sys/bus/platform/devices/ANDR0001:00/properties/android/ skip_initramfs rootwait ro init=/init loop.max_part=7 dm="1 vroot none ro 1,0 5159992 verity 1 PARTUUID=19E87A23-1C27-4616-8116-0088D1F64FD2 PARTUUID=19E87A23-1C27-4616-8116-0088D1F64FD2 4096 4096 644999 644999 sha1 3d4097abf29343cf6b86b9d6703c131e82429f69 5f81fddb8cc753b134fc2901766e57a49cfae566dba7ca48630fdddc30913f84 1 ignore_zero_blocks" androidboot.veritymode=enforcing androidboot.verifiedbootstate=orange root=/dev/dm-0 ramoops.mem_address=0xff018000 ramoops.mem_size=0x10000 memmap=0x10000$0xff018000 qemu.dalvik.vm.heapsize=192m' -android-hw /root/.android/avd/android-28-x86.avd/hardware-qemu.ini
emulator: Android qemu version 29.0.11.0 (build_id 5598178) (CL:N/A)

emulator: Starting QEMU main loop
emulator: Adding boot property: 'ro.opengles.version' = '131072'
emulator: Adding boot property: 'qemu.sf.fake_camera' = 'back'
emulator: Adding boot property: 'qemu.adb.secure' = '1'
emulator: Adding boot property: 'dalvik.vm.heapsize' = '192m'
emuqemu-system-x86_64-headless: warning: host doesn't support requested feature: CPUID.80000001H:ECX.abm [bit 5]
qemu-system-x86_64-headless: warning: host doesn't support requested feature: CPUID.80000001H:ECX.abm [bit 5]
lator: Adding boot property: 'qemu.hw.mainkeys' = '1'
emulator: Adding boot property: 'qemu.sf.lcd_density' = '160'
emulator: goldfish_events.have-dpad: true
emulator: goldfish_events.have-trackball: true
emulator: goldfish_events.have-camera: true
emulator: goldfish_events.have-keyboard: false
emulator: goldfish_events.have-lidswitch: false
emulator: goldfish_events.have-tabletmode: false
emulator: goldfish_events.have-touch: false
emulator: goldfish_events.have-multitouch: true
emulator: control console listening on port 5556, ADB on port 5557
Not using any http proxy
emulator: Adding boot property: 'qemu.timezone' = 'Europe/Kiev'
emulator: android_hw_fingerprint_init: fingerprint qemud listen service initialized

emulator: emulator_window_fb_rotate

emulator: No acpi ini file provided, using default

emulator: Cold boot: requested by the user
emulator: No acpi ini file provided, using default

emulator: _hwFingerprint_connect: connect finger print listen is called

emulator: got message from guest system fingerprint HAL

emulator: onGuestSendCommand: [0xfabb400] Adb connected, start proxing data
emulator: INFO: boot completed
emulator: INFO: boot time 62038 ms
emulator: Increasing screen off timeout, logcat buffer size to 2M.
emulator: Revoking microphone permissions for Google App.

有什么想法吗?

修改: 尝试不使用图形环境. (在〜/.vnc/xstartup中评论了所有内容)没有成功.

Tried w/o graphic environment. (commented all in the ~/.vnc/xstartup ) No success.

试图在命令行中使用 -vnc:2 来实现无头模拟器.没有成功但是输出是不同的.

Tried to use -vnc :2 in the command line to emulator-headless. No success. But the output is different.

...
emulator: Starting QEMU main loop
emulator: Adding boot property: 'ro.opengles.version' = '131072'
qemu-system-x86_64-headless: VNC supports only guest GPU, add "-gpu guest" option
emulator: Done with QEMU main loop

Edit2: 目前尚不清楚为什么直接指定 -vnc:2 会退出.此处: https://android. googlesource.com/platform/external/qemu/+/emu-master-dev/vl.c#4707 :

It is unclear why it quits if I specify -vnc :2 directly. Here: https://android.googlesource.com/platform/external/qemu/+/emu-master-dev/vl.c#4707:

if ((rendererConfig.glesMode == kAndroidGlesEmulationHost) &&
                !QTAILQ_EMPTY(&(qemu_find_opts("vnc")->head))) {
                error_report("VNC supports only guest GPU, add \"-gpu guest\" option");
                return 1;
            }

qemu_find_opts?是否应该成为命令行选项?还是一些配置文件选项?

qemu_find_opts? Is it suppose to be command line options? Or some config file options?

修改3: 如果将 -gpu guest 选项添加到qemu,然后它会响应说这是一个无效选项,这也很有趣. :)

Edit 3: It is also funny if I will add -gpu guest option to qemu and then it will respond that it is an invalid option. :)

推荐答案

解决方案

解决方案是使用独立的vnc服务器. https://stackoverflow.com/a/57651203/10957553

The solution is to use a standalone vnc server. https://stackoverflow.com/a/57651203/10957553

这篇关于带有vnc服务器的无头仿真器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆