1

我正在尝试通过自定义编译内核启动 android 模拟器。我从android存储库下载了金鱼内核并使用了分支origin/android-goldfish-3.10,我能够通过这些命令成功编译内核。

$ export ARCH=x86
$ export CROSS_COMPILE=x86_64-linux-android- 
$ export PATH=$(pwd)/x86_64-linux-android-4.7/bin:$PATH
$ make i386_ranchu_defconfig
$ make -j6
Kernel: arch/x86/boot/bzImage is ready  (#4)

编译内核后,我使用此命令启动了模拟器。

$ cd $ANDROID_SDK_ROOT
$ ./tools/emulator -debug init -kernel $HOME/goldfish/arch/x86/boot/bzImage -system ./system-images/android-22/google_apis/x86/system.img -ramdisk  ./system-images/android-22/google_apis/x86/ramdisk.img  -avd Nexus_5_API_22 -wipe-data -qemu -enable-kvm

它正在启动android模拟器,但模拟器只显示黑屏而不启动。

以下是 android 模拟器日志: 模拟器:找到 AVD 名称 'Nexus_5_API_22' 模拟器:找到 AVD 目标架构:x86 模拟器:找到目录:/home/umer/Android/Sdk/system-images/android-22/google_apis/x86/

emulator:Probing for /home/umer/Android/Sdk/system-images/android-22/google_apis/x86//kernel-ranchu: file exists
emulator:Auto-config: -engine qemu2 (based on configuration)
emulator:  Found directory: /home/umer/Android/Sdk/system-images/android-22/google_apis/x86/

emulator:Found target-specific 64-bit emulator binary: /home/umer/Android/Sdk/tools/qemu/linux-x86_64/qemu-system-i386
emulator:Adding library search path: '/home/umer/Android/Sdk/tools/lib64'
emulator:Adding library search path: '/home/umer/Android/Sdk/tools/lib64/libstdc++'
emulator:  Found directory: /home/umer/Android/Sdk/system-images/android-22/google_apis/x86/

emulator:  Found directory: /home/umer/Android/Sdk/system-images/android-22/google_apis/x86/

emulator:GPU emulation enabled using 'host' mode
emulator: Adding library search path for Qt: '/home/umer/Android/Sdk/tools/lib64/qt/lib'
emulator: Setting Qt plugin search path: QT_QPA_PLATFORM_PLUGIN_PATH=/home/umer/Android/Sdk/tools/lib64/qt/plugins
emulator: Running :/home/umer/Android/Sdk/tools/qemu/linux-x86_64/qemu-system-i386
emulator: qemu backend: argv[00] = "/home/umer/Android/Sdk/tools/qemu/linux-x86_64/qemu-system-i386"
emulator: qemu backend: argv[01] = "-debug"
emulator: qemu backend: argv[02] = "init"
emulator: qemu backend: argv[03] = "-kernel"
emulator: qemu backend: argv[04] = "/home/umer/Android_Project/goldfish/arch/x86/boot/bzImage"
emulator: qemu backend: argv[05] = "-system"
emulator: qemu backend: argv[06] = "./system-images/android-22/google_apis/x86/system.img"
emulator: qemu backend: argv[07] = "-ramdisk"
emulator: qemu backend: argv[08] = "./system-images/android-22/google_apis/x86/ramdisk.img"
emulator: qemu backend: argv[09] = "-avd"
emulator: qemu backend: argv[10] = "Nexus_5_API_22"
emulator: qemu backend: argv[11] = "-wipe-data"
emulator: qemu backend: argv[12] = "-qemu"
emulator: qemu backend: argv[13] = "-enable-kvm"
emulator: Concatenated backend parameters:
 /home/umer/Android/Sdk/tools/qemu/linux-x86_64/qemu-system-i386 -debug init -kernel /home/umer/Android_Project/goldfish/arch/x86/boot/bzImage -system ./system-images/android-22/google_apis/x86/system.img -ramdisk ./system-images/android-22/google_apis/x86/ramdisk.img -avd Nexus_5_API_22 -wipe-data -qemu -enable-kvm
emulator: Android virtual device file at: /home/umer/.android/avd/Nexus_5_API_22.ini
emulator: virtual device content at /home/umer/.android/avd/Nexus_5_API_22.avd
emulator: virtual device config file: /home/umer/.android/avd/Nexus_5_API_22.avd/config.ini
emulator: using core hw config path: /home/umer/.android/avd/Nexus_5_API_22.avd/hardware-qemu.ini
emulator: Found AVD target API level: 22
emulator: Read property file at /home/umer/Android/Sdk/system-images/android-22/google_apis/x86//build.prop
emulator: No boot.prop property file found.
emulator: found skin 'nexus_5' in directory: /home/umer/Android/Sdk/skins/
emulator: autoconfig: -skin nexus_5
emulator: autoconfig: -skindir /home/umer/Android/Sdk/skins/
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: Using initial system image: ./system-images/android-22/google_apis/x86/system.img
emulator: autoconfig: -data /home/umer/.android/avd/Nexus_5_API_22.avd/userdata-qemu.img
emulator: autoconfig: -initdata /home/umer/.android/avd/Nexus_5_API_22.avd/userdata.img
emulator: autoconfig: -cache /home/umer/.android/avd/Nexus_5_API_22.avd/cache.img
emulator: autoconfig: -sdcard /home/umer/.android/avd/Nexus_5_API_22.avd/sdcard.img
emulator: Physical RAM size: 1536MB

emulator: VM heap size 64MB is below hardware specified minimum of 384MB,setting it to that value
emulator: GPU emulation enabled using 'host' mode
emulator: Found 2 DNS servers: 127.0.1.1 8.8.8.8
emulator: trying to load skin file '/home/umer/Android/Sdk/skins//nexus_5/layout'
emulator: Creating: /home/umer/.android/avd/Nexus_5_API_22.avd/userdata-qemu.img

emulator: CPU Acceleration: working
emulator: CPU Acceleration status: KVM (version 12) is installed and usable.
emulator: Using default value for kernel Contiguous Memory Allocation.
emulator: Found 2 DNS servers: 127.0.1.1 8.8.8.8
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 = false
  hw.trackBall = false
  hw.keyboard = true
  hw.keyboard.lid = false
  hw.keyboard.charmap = qwerty2
  hw.dPad = false
  hw.gsmModem = true
  hw.gps = true
  hw.battery = true
  hw.accelerometer = true
  hw.audioInput = true
  hw.audioOutput = true
  hw.sdCard = true
  hw.sdCard.path = /home/umer/.android/avd/Nexus_5_API_22.avd/sdcard.img
  disk.cachePartition = true
  disk.cachePartition.path = /home/umer/.android/avd/Nexus_5_API_22.avd/cache.img
  disk.cachePartition.size = 66m
  hw.lcd.width = 1080
  hw.lcd.height = 1920
  hw.lcd.depth = 16
  hw.lcd.density = 480
  hw.lcd.backlight = true
  hw.gpu.enabled = true
  hw.gpu.mode = host
  hw.gpu.blacklisted = no
  hw.initialOrientation = Portrait
  hw.camera.back = emulated
  hw.camera.front = emulated
  vm.heapSize = 384
  hw.sensors.light = true
  hw.sensors.pressure = true
  hw.sensors.humidity = true
  hw.sensors.proximity = true
  hw.sensors.magnetic_field = true
  hw.sensors.orientation = true
  hw.sensors.temperature = true
  hw.useext4 = true
  kernel.path = /home/umer/Android_Project/goldfish/arch/x86/boot/bzImage
  kernel.newDeviceNaming = yes
  kernel.supportsYaffs2 = no
  disk.ramdisk.path = ./system-images/android-22/google_apis/x86/ramdisk.img
  disk.systemPartition.initPath = ./system-images/android-22/google_apis/x86/system.img
  disk.systemPartition.size = 850m
  disk.dataPartition.path = /home/umer/.android/avd/Nexus_5_API_22.avd/userdata-qemu.img
  disk.dataPartition.initPath = /home/umer/.android/avd/Nexus_5_API_22.avd/userdata.img
  disk.dataPartition.size = 800m
  avd.name = Nexus_5_API_22
.
QEMU options list:
emulator: argv[00] = "/home/umer/Android/Sdk/tools/qemu/linux-x86_64/qemu-system-i386"
emulator: argv[01] = "-dns-server"
emulator: argv[02] = "127.0.1.1,8.8.8.8"
emulator: argv[03] = "-serial"
emulator: argv[04] = "null"
emulator: argv[05] = "-enable-kvm"
emulator: argv[06] = "-smp"
emulator: argv[07] = "cores=2"
emulator: argv[08] = "-m"
emulator: argv[09] = "1536"
emulator: argv[10] = "-append"
emulator: argv[11] = "qemu=1 androidboot.hardware=ranchu clocksource=pit android.qemud=1 console=0 console=0 android.checkjni=1 qemu.gles=1 ndns=2"
emulator: argv[12] = "-lcd-density"
emulator: argv[13] = "480"
emulator: argv[14] = "-kernel"
emulator: argv[15] = "/home/umer/Android_Project/goldfish/arch/x86/boot/bzImage"
emulator: argv[16] = "-initrd"
emulator: argv[17] = "./system-images/android-22/google_apis/x86/ramdisk.img"
emulator: argv[18] = "-drive"
emulator: argv[19] = "if=none,index=0,id=system,file=./system-images/android-22/google_apis/x86/system.img"
emulator: argv[20] = "-device"
emulator: argv[21] = "virtio-blk-pci,drive=system"
emulator: argv[22] = "-drive"
emulator: argv[23] = "if=none,index=1,id=cache,file=/home/umer/.android/avd/Nexus_5_API_22.avd/cache.img"
emulator: argv[24] = "-device"
emulator: argv[25] = "virtio-blk-pci,drive=cache"
emulator: argv[26] = "-drive"
emulator: argv[27] = "if=none,index=2,id=userdata,file=/home/umer/.android/avd/Nexus_5_API_22.avd/userdata-qemu.img"
emulator: argv[28] = "-device"
emulator: argv[29] = "virtio-blk-pci,drive=userdata"
emulator: argv[30] = "-drive"
emulator: argv[31] = "if=none,index=3,id=sdcard,file=/home/umer/.android/avd/Nexus_5_API_22.avd/sdcard.img"
emulator: argv[32] = "-device"
emulator: argv[33] = "virtio-blk-pci,drive=sdcard"
emulator: argv[34] = "-netdev"
emulator: argv[35] = "user,id=mynet"
emulator: argv[36] = "-device"
emulator: argv[37] = "virtio-net-pci,netdev=mynet"
emulator: argv[38] = "-show-cursor"
emulator: argv[39] = "-L"
emulator: argv[40] = "/home/umer/Android/Sdk/tools/lib/pc-bios"
emulator: argv[41] = "-vga"
emulator: argv[42] = "none"
emulator: argv[43] = "-enable-kvm"
emulator: argv[44] = "-android-hw"
emulator: argv[45] = "/home/umer/.android/avd/Nexus_5_API_22.avd/hardware-qemu.ini"
Concatenated QEMU options:
 /home/umer/Android/Sdk/tools/qemu/linux-x86_64/qemu-system-i386 -dns-server 127.0.1.1,8.8.8.8 -serial null -enable-kvm -smp cores=2 -m 1536 -append 'qemu=1 androidboot.hardware=ranchu clocksource=pit android.qemud=1 console=0 console=0 android.checkjni=1 qemu.gles=1 ndns=2' -lcd-density 480 -kernel /home/umer/Android_Project/goldfish/arch/x86/boot/bzImage -initrd ./system-images/android-22/google_apis/x86/ramdisk.img -drive if=none,index=0,id=system,file=./system-images/android-22/google_apis/x86/system.img -device virtio-blk-pci,drive=system -drive if=none,index=1,id=cache,file=/home/umer/.android/avd/Nexus_5_API_22.avd/cache.img -device virtio-blk-pci,drive=cache -drive if=none,index=2,id=userdata,file=/home/umer/.android/avd/Nexus_5_API_22.avd/userdata-qemu.img -device virtio-blk-pci,drive=userdata -drive if=none,index=3,id=sdcard,file=/home/umer/.android/avd/Nexus_5_API_22.avd/sdcard.img -device virtio-blk-pci,drive=sdcard -netdev user,id=mynet -device virtio-net-pci,netdev=mynet -show-cursor -L /home/umer/Android/Sdk/tools/lib/pc-bios -vga none -enable-kvm -android-hw /home/umer/.android/avd/Nexus_5_API_22.avd/hardware-qemu.ini
emulator: Starting QEMU main loop
emulator: registered 'boot-properties' qemud service
emulator: Adding boot property: 'qemu.sf.fake_camera' = 'both'
emulator: Initializing hardware OpenGLES emulation support
emulator: Adding boot property: 'ro.opengles.version' = '131072'
emulator: Adding boot property: 'dalvik.vm.heapsize' = '384m'
emulator: Adding boot property: 'qemu.hw.mainkeys' = '0'
emulator: Adding boot property: 'qemu.sf.lcd_density' = '480'
emulator: goldfish_events.have-dpad: false
emulator: goldfish_events.have-trackball: false
emulator: goldfish_events.have-camera: true
emulator: goldfish_events.have-keyboard: true
emulator: goldfish_events.have-lidswitch: false
emulator: goldfish_events.have-touch: false
emulator: goldfish_events.have-multitouch: true
emulator: Listening for console connections on port: 5554
emulator: Serial number of this emulator (for ADB): emulator-5554
emulator: android_hw_fingerprint_init: fingerprint qemud listen service initialized

emulator: Window was not fully visible: monitor=[0,0,1297,729] window=[130,214,333,584]
emulator: Window repositioned to [482,72]
emulator: emulator window was out of view and was recentered

在此处输入图像描述

我正在使用 Android Lollipop API 级别 22 的默认图像。

4

1 回答 1

1

Android 预构建系统映像带有-gpu on标志。您需要-gpu off显式传递才能使用自定义内核运行模拟器。

命令:

$ ./tools/emulator -gpu off -debug init -kernel $HOME/goldfish/arch/x86/boot/bzImage -system ./system-images/android-22/google_apis/x86/system.img -ramdisk  ./system-images/android-22/google_apis/x86/ramdisk.img  -avd Nexus_5_API_22 -wipe-data -qemu -enable-kvm
于 2016-10-09T15:52:52.527 回答