Ubuntu 20.04编译AOSP 并启动模拟器
Posted ansondroider
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Ubuntu 20.04编译AOSP 并启动模拟器相关的知识,希望对你有一定的参考价值。
平台
CPU: Intel® Core™ i7-8700 CPU @ 3.20GHz
DDR: 24GB
硬盘: SSD 1TB
系统: Ubuntu 20.04 x64
概述
疫情期间居家办公, 为方便调试, 从清华镜像下载了AOSP的代码准备编译后尝试使用模拟器调试, 编译完成后, 发现模拟器启动不了, 要么卡死, 要么崩溃, 历经波折, 最终更新后得以解决, 特此记录.
环境搭建
参考, 建议以官方说明或厂商开发文档中的环境搭建说明为主
#JDK
sudo add-apt-repository ppa:openjdk-r/ppa
sudo apt-get update
#sudo apt-get install openjdk-7-jdk
sudo apt-get install openjdk-8-jdk
sudo apt-get install vim
sudo apt-get install minicom
#追加源
sudo gedit /etc/apt/sources.list
+ deb http://us.archive.ubuntu.com/ubuntu trusty main universe
sudo apt-get update
#安装依赖
sudo apt-get install git gnupg flex bison gperf build-essential zip curl libc6-dev libncurses5-dev:i386 x11proto-core-dev libx11-dev:i386 libreadline6-dev:i386 libgl1-mesa-glx:i386 libgl1-mesa-dev g++-multilib tofrodos python-markdown libxml2-utils xsltproc zlib1g-dev:i386
sudo apt-get install lzop libncurses5
sudo ln -s /usr/lib/i386-linux-gnu/mesa/libGL.so.1 /usr/lib/i386-linux-gnu/libGL.so
sudo apt-get install mingw32
sudo apt-get install automake make perl gcc g++
sudo apt-get install libncurses5
# make kernel
# scripts/extract-cert.c:21:10: fatal error: openssl/bio.h: No such file or directory
# 21 | #include <openssl/bio.h>
# | ^~~~~~~~~~~~~~~
sudo apt-get install libssl-dev
#android编译环境补充
sudo ln -sf /usr/bin/python2.7 /usr/bin/python
#ifconfig
sudo apt install net-tools
# 编译RK3399_LINUX 时出现: [awk: line 2: function strtonum never defined] https://blog.csdn.net/liangtianmeng/article/details/86020254
sudo apt-get install gawk
## Android 11 u-boot
sudo apt-get install device-tree-compiler
## X2000 kernel
sudo apt install u-boot-tools
## make menuconfig 失败
sudo apt-get install libncurses5-dev
获取源码并编译
下载:
Android 镜像使用帮助
编译:
source ./build/envsetup.sh
#官网中使用的是: lunch aosp_arm-eng
#由于需要使用模拟器等相关开发环境, 本文编译直接使用,
# 见 https://source.android.com/setup/create/avd
lunch sdk_phone_x86_64
make -j12
编译时长:
#### build completed successfully (02:11:17 (hh:mm:ss)) ####
启动模拟器:
## 在编译完成后可以直接运行
## 若关闭了终端, 或重新加载了环境, 则有可能导致执行错误,
## 建议执行前确认是否已经执行
## source ./build/envsetup.sh
## lunch xxxx
$ emulator
官网说明
模拟器启动成功
一些问题
编译问题
- Linux ps 命令导致AOSP编译失败
- 内存至少16GB, 刚开始只用8G, 单线程编译也会卡死.
模拟器无法正常启动
最早下载源码的时间是2022年3月1日
而直至2022年4月17日才成功把模拟器成功跑起来.
而解决的方法: 同步到最新 同步到最新 同步到最新
旧的代码第一次编译完成后, 无法启动
$source build/envsetup.sh
$lunch sdk_x86_64
$make
$emulator
INFO | Android emulator version 31.3.5.0 (build_id 8311694) (CL:N/A)
INFO | Duplicate loglines will be removed, if you wish to see each indiviudal line launch with the -log-nofilter flag.
WARNING | encryption is off
WARNING | cannot add library /media/anson/codes/aosp/prebuilts/android-emulator/linux-x86_64/qemu/linux-x86_64/lib64/vulkan/libvulkan.so: failed
INFO | added library /media/anson/codes/aosp/prebuilts/android-emulator/linux-x86_64/lib64/vulkan/libvulkan.so
MESA-INTEL: warning: Performance support disabled, consider sysctl dev.i915.perf_stream_paranoid=0
INFO | configAndStartRenderer: setting vsync to 60 hz
WARNING | *** No gRPC protection active, consider launching with the -grpc-use-jwt flag.***
INFO | Started GRPC server at 127.0.0.1:8554, security: Local:none
INFO | Advertising in: /run/user/1000/avd/running/pid_6593.ini
pulseaudio: set_sink_input_volume() failed
pulseaudio: Reason: Invalid argument
pulseaudio: set_sink_input_mute() failed
pulseaudio: Reason: Invalid argument
ERROR | Unable to connect to adb daemon on port: 5037
$emulator
INFO | Android emulator version 31.3.5.0 (build_id 8311694) (CL:N/A)
INFO | Duplicate loglines will be removed, if you wish to see each indiviudal line launch with the -log-nofilter flag.
ERROR | No initial system image for this configuration!
刚开始怀疑是系统环境问题, 于是又配置了硬件加速还有虚拟技术等功能检测12
而后, 根据3提示, 增加命令参数以显示更多的启动信息(增加 -verbose -show-kernel -shell):
$ emulator -verbose -show-kernel -shell
INFO | Android emulator version 31.3.5.0 (build_id 8311694) (CL:N/A)
INFO | Found ANDROID_PRODUCT_OUT: /media/anson/codes/aosp/out/target/product/emulator_x86
INFO | Found build target architecture: x86
INFO | argv[0]: 'emulator'; program directory: '/media/anson/codes/aosp/prebuilts/android-emulator/linux-x86_64'
INFO | emuDirName: '/media/anson/codes/aosp/prebuilts/android-emulator/emulator'
INFO | Probing for /media/anson/codes/aosp/out/target/product/emulator_x86/kernel-ranchu-64: file missing
INFO | try dir /media/anson/codes/aosp/prebuilts/android-emulator/linux-x86_64
INFO | Trying emulator path '/media/anson/codes/aosp/prebuilts/android-emulator/linux-x86_64/qemu/linux-x86_64/qemu-system-i386'
INFO | Found target-specific 64-bit emulator binary: /media/anson/codes/aosp/prebuilts/android-emulator/linux-x86_64/qemu/linux-x86_64/qemu-system-i386
INFO | Adding library search path: '/media/anson/codes/aosp/prebuilts/android-emulator/linux-x86_64/lib64'
INFO | Adding library search path: '/media/anson/codes/aosp/prebuilts/android-emulator/linux-x86_64/lib64/gles_swiftshader'
INFO | Adding library search path: '/media/anson/codes/aosp/prebuilts/android-emulator/linux-x86_64/lib64/libstdc++'
VERBOSE | Adding library search path for Qt: '/media/anson/codes/aosp/prebuilts/android-emulator/linux-x86_64/lib64/qt/lib'
VERBOSE | Silencing all qWarning(); use qCWarning(...) instead: QT_LOGGING_RULES=default.warning=false
VERBOSE | Setting Qt plugin search path: QT_QPA_PLATFORM_PLUGIN_PATH=/media/anson/codes/aosp/prebuilts/android-emulator/linux-x86_64/lib64/qt/plugins
VERBOSE | Setting Qt to use software OpenGL: QT_OPENGL=software
VERBOSE | Setting QML to use software QtQuick2D: QMLSCENE_DEVICE=softwarecontext
VERBOSE | Overriding pre-existing bad Qt high dpi settings...
VERBOSE | Setting LD_PRELOAD to /media/anson/codes/aosp/prebuilts/android-emulator/linux-x86_64/lib64/qt/lib/libfreetype.so.6
VERBOSE | emulator: Running :/media/anson/codes/aosp/prebuilts/android-emulator/linux-x86_64/qemu/linux-x86_64/qemu-system-i386
VERBOSE | qemu backend: argv[00] = "/media/anson/codes/aosp/prebuilts/android-emulator/linux-x86_64/qemu/linux-x86_64/qemu-system-i386"
VERBOSE | qemu backend: argv[01] = "-verbose"
VERBOSE | qemu backend: argv[02] = "-show-kernel"
VERBOSE | qemu backend: argv[03] = "-shell"
VERBOSE | Concatenated backend parameters: /media/anson/codes/aosp/prebuilts/android-emulator/linux-x86_64/qemu/linux-x86_64/qemu-system-i386 -verbose -show-kernel -shell
INFO | Duplicate loglines will be removed, if you wish to see each indiviudal line launch with the -log-nofilter flag.
VERBOSE | found Android build root: /media/anson/codes/aosp
VERBOSE | found Android build out: /media/anson/codes/aosp/out/target/product/emulator_x86
VERBOSE | Cannot find boot properties file: /media/anson/codes/aosp/out/target/product/emulator_x86/boot.prop
VERBOSE | Found target API sdkVersion: 32
VERBOSE | Invalid int property: 'ro.build.version.incremental:eng.anson.20220320.212450'
VERBOSE | autoconfig: -skin HVGA
VERBOSE | autoconfig: -skindir /media/anson/codes/aosp/development/tools/emulator/skins/
VERBOSE | autoconfig: -kernel /media/anson/codes/aosp/prebuilts/qemu-kernel/x86/ranchu/kernel-qemu
VERBOSE | Target arch = 'x86'
VERBOSE | Auto-config: -qemu -cpu qemu32
VERBOSE | Auto-detect: Kernel image requires new device naming scheme.
VERBOSE | Auto-detect: Kernel does not support YAFFS2 partitions.
VERBOSE | autoconfig: -ramdisk /media/anson/codes/aosp/out/target/product/emulator_x86/ramdisk-qemu.img
VERBOSE | autoconfig: -sysdir /media/anson/codes/aosp/out/target/product/emulator_x86
VERBOSE | Using direct system image: /media/anson/codes/aosp/out/target/product/emulator_x86/system-qemu.img
VERBOSE | system partition size adjusted to match image file (4107 MB > 800 MB)
VERBOSE | Using direct vendor image: /media/anson/codes/aosp/out/target/product/emulator_x86/vendor-qemu.img
VERBOSE | autoconfig: -data /media/anson/codes/aosp/out/target/product/emulator_x86/userdata-qemu.img
VERBOSE | autoconfig: -initdata /media/anson/codes/aosp/out/target/product/emulator_x86/userdata.img
VERBOSE | autoconfig: -cache /media/anson/codes/aosp/out/target/product/emulator_x86/cache.img
VERBOSE | Increasing RAM size to 2048MB
VERBOSE | VM heap size 48MB is below hardware specified minimum of 512MB,setting it to that value
VERBOSE | System image is read only
VERBOSE | Found 1 DNS servers:
VERBOSE | 127.0.0.53
VERBOSE | trying to load skin file '/media/anson/codes/aosp/development/tools/emulator/skins//HVGA/layout'
WARNING | encryption is off
VERBOSE | CPU Acceleration: working
VERBOSE | CPU Acceleration status: KVM (version 12) is installed and usable.
VERBOSE | handleCpuAcceleration: feature check for hvf
VERBOSE | GPU emulation enabled using 'host' mode
VERBOSE | Initializing hardware OpenGLES emulation support
VERBOSE | create display 0
VERBOSE | setDisplayPose 0 x 0 y 0 w 320 h 480 dpi 0
WARNING | cannot add library /media/anson/codes/aosp/prebuilts/android-emulator/linux-x86_64/qemu/linux-x86_64/lib64/vulkan/libvulkan.so: failed
INFO | added library /media/anson/codes/aosp/prebuilts/android-emulator/linux-x86_64/lib64/vulkan/libvulkan.so
MESA-INTEL: warning: Performance support disabled, consider sysctl dev.i915.perf_stream_paranoid=0
INFO | configAndStartRenderer: setting vsync to 60 hz
VERBOSE | Found 1 DNS servers:
VERBOSE | 127.0.0.53
INFO | Content of hardware configuration file:
INFO | hw.cpu.arch = x86
INFO | hw.cpu.model = qemu32
INFO | hw.cpu.ncore = 2
INFO | hw.ramSize = 2048
INFO | hw.screen = multi-touch
INFO | hw.mainKeys = true
INFO | hw.trackBall = true
INFO | hw.keyboard = false
INFO | hw.keyboard.lid = false
INFO | hw.keyboard.charmap = qwerty2
INFO | hw.dPad = true
INFO | hw.rotaryInput = false
INFO | hw.gsmModem = true
INFO | hw.gps = true
INFO | hw.battery = true
INFO | hw.accelerometer = true
INFO | hw.gyroscope = true
INFO | hw.audioInput = true
INFO | hw.audioOutput = true
INFO | hw.sdCard = true
INFO | disk.cachePartition = true
INFO | disk.cachePartition.path = /media/anson/codes/aosp/out/target/product/emulator_x86/cache.img
INFO | disk.cachePartition.size = 66m
INFO | test.quitAfterBootTimeOut = -1
INFO | test.delayAdbTillBootComplete = 0
INFO | test.monitorAdb = 0
INFO | hw.lcd.width = 320
INFO | hw.lcd.height = 480
INFO | hw.lcd.depth = 16
INFO | hw.lcd.density = 160
INFO | hw.lcd.backlight = true
INFO | hw.lcd.vsync = 60
INFO | hw.gltransport = pipe
INFO | hw.gltransport.asg.writeBufferSize = 1048576
INFO | hw.gltransport.asg.writeStepSize = 4096
INFO | hw.gltransport.asg.dataRingSize = 32768
INFO | hw.gltransport.drawFlushInterval = 800
INFO | hw.displayRegion.0.1.xOffset = -1
INFO | hw.displayRegion.0.1.yOffset = -1
INFO | hw.displayRegion.0.1.width = 0
INFO | hw.displayRegion.0.1.height = 0
INFO | hw.displayRegion.0.2.xOffset = -1
INFO | hw.displayRegion.0.2.yOffset = -1
INFO | hw.displayRegion.0.2.width = 0
INFO | hw.displayRegion.0.2.height = 0
INFO | hw.displayRegion.0.3.xOffset = -1
INFO | hw.displayRegion.0.3.yOffset = -1
INFO | hw.displayRegion.0.3.width = 0
INFO | hw.displayRegion.0.3.height = 0
INFO | hw.display1.width = 0
INFO | hw.display1.height = 0
INFO | hw.display1.density = 0
INFO | hw.display1.xOffset = -1
INFO | hw.display1.yOffset = -1
INFO | hw.display1.flag = 0
INFO | hw.display2.width = 0
INFO | hw.display2.height = 0
INFO | hw.display2.density = 0
INFO | hw.display2.xOffset = -1
INFO | hw.display2.yOffset = -1
INFO | hw.display2.flag = 0
INFO | hw.display3.width = 0
INFO | hw.display3.height = 0
INFO | hw.display3.density = 0
INFO | hw.display3.xOffset = -1
INFO | hw.display3.yOffset = -1
INFO | hw.display3.flag = 0
INFO | hw.multi_display_window = false
INFO | hw.gpu.enabled = true
INFO | hw.gpu.mode = host
INFO | hw.initialOrientation = portrait
INFO | hw.camera.back = emulated
INFO | hw.camera.front = none
INFO | vm.heapSize = 512
INFO | hw.sensors.light = true
INFO | hw.sensors.pressure = true
INFO | hw.sensors.humidity = true
INFO | hw.sensors.proximity = true
INFO | hw.sensors.magnetic_field = true
INFO | hw.sensors.magnetic_field_uncalibrated = true
INFO | hw.sensors.gyroscope_uncalibrated = true
INFO | hw.sensors.orientation = true
INFO | hw.sensors.temperature = true
INFO | hw.sensors.rgbclight = false
INFO | hw.sensor.hinge = false
INFO | hw.sensor.hinge.count = 0
INFO | hw.sensor.hinge.type = 0
INFO | hw.sensor.hinge.sub_type = 0
INFO | hw.sensor.hinge.fold_to_displayRegion.0.1_at_posture = 1
INFO | hw.sensor.roll = false
INFO | hw.sensor.roll.count = 0
INFO | hw.sensor.roll.resize_to_displayRegion.0.1_at_posture = 6
INFO | hw.sensor.roll.resize_to_displayRegion.0.2_at_posture = 6
INFO | hw.sensor.roll.resize_to_displayRegion.0.3_at_posture = 6
INFO | hw.sensors.heart_rate = false
INFO | hw.sensors.wrist_tilt = false
INFO | hw.useext4 = true
INFO | hw.arc = false
INFO | hw.arc.autologin = false
INFO | kernel.path = /media/anson/codes/aosp/prebuilts/qemu-kernel/x86/ranchu/kernel-qemu
INFO | kernel.newDeviceNaming = yes
INFO | kernel.supportsYaffs2 = no
INFO | disk.ramdisk.path = /media/anson/codes/aosp/out/target/product/emulator_x86/ramdisk-qemu.img
INFO | disk.systemPartition.path = /media/anson/codes/aosp/out/target/product/emulator_x86/system-qemu.img
INFO | disk.systemPartition.size = 4107m
INFO | disk.vendorPartition.path = /media/anson/codes/aosp/out/target/product/emulator_x86/vendor-qemu.img
INFO | disk.vendorPartition.size = 800m
INFO | disk.dataPartition.path = /media/anson/codes/aosp/out/target/product/emulator_x86/userdata-qemu.img
INFO | disk.dataPartition.size = 800m
INFO | PlayStore.enabled = false
INFO | avd.name = <build>
INFO | avd.id = <build>
INFO | fastboot.forceColdBoot = false
INFO | android.avd.home = /home/anson/.android/avd
INFO | .
INFO | QEMU options list:
INFO | argv[00] = "/media/anson/codes/aosp/prebuilts/android-emulator/linux-x86_64/qemu/linux-x86_64/qemu-system-i386"
INFO | argv[01] = "-dns-server"
INFO | argv[02] = "127.0.0.53"
INFO | argv[03] = "-mem-path"
INFO | argv[04] = "/media/anson/codes/aosp/out/target/product/emulator_x86/snapshots/default_boot/ram.img"
INFO | argv[05] = "-mem-file-shared"
INFO | argv[06] = "-serial"
INFO | argv[07] = "stdio"
INFO | argv[08] = "-device"
INFO | argv[09] = "goldfish_pstore,addr=0xff018000,size=0x10000,file=/media/anson/codes/aosp/out/target/product/emulator_x86/build.avd/data/misc/pstore/pstore.bin"
INFO | argv[10] = "-cpu"
INFO | argv[11] = "android32"
INFO | argv[12] = "-enable-kvm"
INFO | argv[13] = "-smp"
INFO | argv[14] = "cores=2"
INFO | argv[15] = "-m"
INFO | argv[16] = "2048"
INFO | argv[17] = "-lcd-density"
INFO | argv[18] = "160"
INFO | argv[19] = "-object"
INFO | argv[20] = "iothread,id=disk-iothread"
INFO | argv[21] = "-nodefaults"
INFO | argv[22] = "-kernel"
INFO | argv[23] = "/media/anson/codes/aosp/prebuilts/qemu-kernel/x86/ranchu/kernel-qemu"
INFO | argv[24] = "-initrd"
INFO | argv[25] = "/media/anson/codes/aosp/out/target/product/emulator_x86/ramdisk-qemu.img"
INFO | argv[26] = "-drive"
INFO | argv[27] = "if=none,index=0,id=system,if=none,file=/media/anson/codes/aosp/out/target/product/emulator_x86/system-qemu.img,read-only"
INFO | argv[28] = "-device"
INFO | argv[29] = "virtio-blk-pci,drive=system,iothread=disk-iothread,modern-pio-notify"
INFO | argv[30] = "-drive"
INFO | argv[31] = "if=none,index=1,id=cache,if=none,file=/media/anson/codes/aosp/out/target/product/emulator_x86/cache.img.qcow2,overlap-check=none,cache=unsafe,l2-cache-size=1048576"
INFO | argv[32] = "-device"
INFO | argv[33] = "virtio-blk-pci,drive=cache,iothread=disk-iothread,modern-pio-notify"
INFO | argv[34] = "-drive"
INFO | argv[35] = "if=none,index=2,id=userdata,if=none,file=/media/anson/codes/aosp/out/target/product/emulator_x86/userdata-qemu.img.qcow2,overlap-check=none,cache=unsafe,l2-cache-size=1048576"
INFO | argv[36] = "-device"
INFO | argv[37] = "virtio-blk-pci,drive=userdata,iothread=disk-iothread,modern-pio-notify"
INFO | argv[38] = "-drive"
INFO | argv[39] = "if=none,index=3,id=vendor,if=none,file=/media/anson/codes/aosp/out/target/product/emulator_x86/vendor-qemu.img,read-only"
INFO | argv[40] = "-device"
INFO | argv[41] = "virtio-blk-pci,drive=vendor,iothread=disk-iothread,modern-pio-notify"
INFO | argv[42] = "-netdev"
INFO | argv[43] = "user,id=mynet"
INFO | argv[44] = "-device"
INFO | argv[45] = "virtio-net-pci,netdev=mynet"
INFO | argv[46] = "-device"
INFO | argv[47] = "virtio-rng-pci"
INFO | argv[48] = "-show-cursor"
INFO | argv[49] = "-L"
INFO | argv[50] = "/media/anson/codes/aosp/prebuilts/android-emulator/linux-x86_64/lib/pc-bios"
INFO | argv[51] = "-soundhw"
INFO | argv[52] = "hda"
INFO | argv[53] = "-vga"
INFO | argv[54] = "none"
INFO | argv[55] = "-append"
INFO | argv[56] = "no_timer_check clocksource=pit no-kvmclock console=ttyS0,38400 cma=4M@0-4G loop.max_part=7 ramoops.mem_address=0xff018000 ramoops.mem_size=0x10000 memmap=0x10000$0xff018000 printk.devkmsg=on qemu=1 androidboot.hardware=ranchu androidboot.serialno=EMULATOR31X3X5X0 qemu.gles=1 qemu.settings.system.screen_off_timeout=1800000 qemu.vsync=60 qemu.gltransport=pipe qemu.gltransport.drawFlushInterval=800 qemu.opengles.version=131072 qemu.dalvik.vm.heapsize=512m qemu.camera_protocol_ver=1 qemu.camera_hq_edge_processing=0 androidboot.android_dt_dir=/sys/bus/platform/devices/ANDR0001:00/properties/android/ androidboot.vbmeta.size=6208 androidboot.vbmeta.hash_alg=sha256 androidboot.vbmeta.digest=1bdf25ee647d5053e6881a5652319e178099c4abef0cfb12263f62cadccfd971 androidboot.console=ttyS0 android.qemud=1 qemu.avd_name=<build>"
INFO | argv[57] = "-android-hw"
INFO | argv[58] = "/media/anson/codes/aosp/out/target/product/emulator_x86/hardware-qemu.ini"
INFO | Concatenated QEMU options: /media/anson/codes/aosp/prebuilts/android-emulator/linux-x86_64/qemu/linux-x86_64/qemu-system-i386 -dns-server 127.0.0.53 -mem-path /media/anson/codes/aosp/out/target/product/emulator_x86/snapshots/default_boot/ram.img -mem-file-shared -serial stdio -device goldfish_pstore,addr=0xff018000,size=0x10000,file=/media/anson/codes/aosp/out/target/product/emulator_x86/build.avd/data/misc/pstore/pstore.bin -cpu android32 -enable-kvm -smp cores=2 -m 2048 -lcd-density 160 -object iothread,id=disk-iothread -nodefaults -kernel /media/anson/codes/aosp/prebuilts/qemu-kernel/x86/ranchu/kernel-qemu -initrd /media/anson/codes/aosp/out/target/product/emulator_x86/ramdisk-qemu.img -drive if=none,index=0,id=system,if=none,file=/media/anson/codes/aosp/out/target/product/emulator_x86/system-qemu.img,read-only -device virtio-blk-pci,drive=system,iothread=disk-iothread,modern-pio-notify -drive if=none,index=1,id=cache,if=none,file=/media/anson/codes/aosp/out/target/product/emulator_x86/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,if=none,file=/media/anson/codes/aosp/out/target/product/emulator_x86/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=vendor,if=none,file=/media/anson/codes/aosp/out/target/product/emulator_x86/vendor-qemu.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 /media/anson/codes/aosp/prebuilts/android-emulator/linux-x86_64/lib/pc-bios -soundhw hda -vga none -append 'no_timer_check clocksource=pit no-kvmclock console=ttyS0,38400 cma=4M@0-4G loop.max_part=7 ramoops.mem_address=0xff018000 ramoops.mem_size=0x10000 memmap=0x10000$0xff018000 printk.devkmsg=on qemu=1 androidboot.hardwa
VERBOSE | Android qemu version 31.3.5.0 (build_id 8311694) (CL:N/A)
VERBOSE | Starting QEMU main loop
VERBOSE | registered 'boot-properties' qemud service
VERBOSE | Adding boot property: 'ro.opengles.version' = '131072'
VERBOSE | Adding boot property: 'qemu.sf.fake_camera' = 'back'
VERBOSE | Adding boot property: 'dalvik.vm.heapsize' = '512m'
VERBOSE | Adding boot property: 'qemu.hw.mainkeys' = '1'
VERBOSE | Adding boot property: 'qemu.sf.lcd_density' = '160'
VERBOSE | control console listening on port 5554, ADB on port 5555
VERBOSE | goldfish_events.have-dpad: true
VERBOSE | goldfish_events.have-trackball: true
VERBOSE | goldfish_events.have-camera: true
VERBOSE | goldfish_events.have-keyboard: false
VERBOSE | goldfish_events.have-lidswitch: false
VERBOSE | goldfish_events.have-tabletmode: false
VERBOSE | goldfish_events.have-touch: false
VERBOSE | goldfish_events.have-multitouch: true
VERBOSE | Not using any http proxy
VERBOSE | Adding boot property: 'qemu.timezone' = 'Asia/Shanghai'
VERBOSE | android_hw_fingerprint_init: fingerprint qemud listen service initialized
WARNING | *** No gRPC protection active, consider launching with the -grpc-use-jwt flag.***
INFO | Started GRPC server at 127.0.0.1:8554, security: Local:none
INFO | Advertising in: /run/user/1000/avd/running/pid_7963.ini
VERBOSE | emulator_window_fb_rotate
VERBOSE | No acpi ini file provided, using default
VERBOSE | Adding boot property: 'ro.opengles.version' = '131072'
VERBOSE | Adding boot property: 'qemu.sf.fake_camera' = 'back'
VERBOSE | Adding boot property: 'dalvik.vm.heapsize' = '512m'
VERBOSE | Adding boot property: 'qemu.hw.mainkeys' = '1'
VERBOSE | Adding boot property: 'qemu.sf.lcd_density' = '160'
VERBOSE | Adding boot property: 'qemu.timezone' = 'Asia/Shanghai'
pulseaudio: set_sink_input_volume() failed
pulseaudio: Reason: Invalid argument
pulseaudio: set_sink_input_mute() failed
pulseaudio: Reason: Invalid argument
VERBOSE | no root specified:
qemu-system-i386: warning: TSC frequency mismatch between VM (3191998 kHz) and host (3191999 kHz), and TSC scaling unavailable
qemu-system-i386: warning: TSC frequency mismatch between VM (3191998 kHz) and host (3191999 kHz), and TSC scaling unavailable
VERBOSE | Path:/media/anson/codes/aosp/out/host/linux-x86/bin/adb protocol version: 41
VERBOSE | Path:/media/anson/codes/aosp/out/host/linux-x86/bin/adb protocol version: 41
VERBOSE | Found: 1 adb executables
VERBOSE | Adb: /media/anson/codes/aosp/out/host/linux-x86/bin/adb
VERBOSE | Path:/media/anson/codes/aosp/out/host/linux-x86/bin/adb protocol version: 41
ERROR | Unable to connect to adb daemon on port: 5037
VERBOSE | No acpi ini file provided, using default
[ 0.000000] Initializing cgroup subsys cpu
[ 0.000000] Initializing cgroup subsys cpuacct
[ 0.000000] Linux version 3.18.94+ (android-build@xpcc10.ams.corp.google.com) (gcc version 4.9 20140827 (prerelease) (GCC) ) #1 SMP PREEMPT Mon Feb 12 19:52:31 UTC 2018
[ 0.000000] e820: BIOS-provided physical RAM map:
[ 0.000000] BIOS-e820: [mem 0x0000000000000000-0x000000000009fbff] usable
[ 0.000000] BIOS-e820: [mem 0x000000000009fc00-0x000000000009ffff] reserved
[ 0.000000] BIOS-e820: [mem 0x00000000000f0000-0x00000000000fffff] reserved
[ 0.000000] B无法在 Linux (Ubuntu 15.10) 上启动模拟器
【中文标题】无法在 Linux (Ubuntu 15.10) 上启动模拟器【英文标题】:Cannot launch emulator on Linux (Ubuntu 15.10)
【发布时间】:2016-06-24 23:47:28
【问题描述】:
我尝试启动模拟器,但它输出到日志中:
libGL error: unable to load driver: r600_dri.so
libGL error: driver pointer missing
libGL error: failed to load driver: r600
libGL error: unable to load driver: swrast_dri.so
libGL error: failed to load driver: swrast
X Error of failed request: GLXBadContext
Major opcode of failed request: 155 (GLX)
Minor opcode of failed request: 6 (X_GLXIsDirect)
Serial number of failed request: 47
Current serial number in output stream: 46
libGL error: unable to load driver: r600_dri.so
libGL error: driver pointer missing
libGL error: failed to load driver: r600
libGL error: unable to load driver: swrast_dri.so
libGL error: failed to load driver: swrast
X Error of failed request: GLXBadContext
Major opcode of failed request: 155 (GLX)
Minor opcode of failed request: 6 (X_GLXIsDirect)
Serial number of failed request: 47
Current serial number in output stream: 46
libGL error: unable to load driver: r600_dri.so
libGL error: driver pointer missing
libGL error: failed to load driver: r600
libGL error: unable to load driver: swrast_dri.so
libGL error: failed to load driver: swrast
X Error of failed request: BadValue (integer parameter out of range for operation)
Major opcode of failed request: 155 (GLX)
Minor opcode of failed request: 24 (X_GLXCreateNewContext)
Value in failed request: 0x0
Serial number of failed request: 33
Current serial number in output stream: 34
QObject::~QObject: Timers cannot be stopped from another thread emulator: WARNING: Increasing RAM size to 1GB
如何解决?我阅读了有类似错误的主题,但这对我没有帮助。
【问题讨论】:
在这里找到一个方便的解决方案,而不需要在这个答案中给出额外的:[github.com/rimian/cordova-ember-android]
【参考方案1】:
使用系统中可用的 libstdc++.so.6 而不是与 android sdk 捆绑的那个可以解决此问题。
模拟器有一个开关-use-system-libs
来执行此操作。
~/Android/Sdk/tools/emulator -avd Nexus_5_API_23 -use-system-libs
或者,您可以为您的用户/系统将ANDROID_EMULATOR_USE_SYSTEM_LIBS
环境变量设置为1
。这样做的好处是,即使您从 Android Studio 中启动模拟器,它也能正常工作。
更多详情:https://code.google.com/p/android/issues/detail?id=197254#c15
【讨论】:
然后,当您尝试运行您的应用时,您的 Android Studio 中会出现一个已连接的设备(在本例中为 Nexus_5_API_23)。
这是 imo 的最佳答案,因为模拟器可以通过 shell 脚本正确启动,而无需移动或链接现有的 sdk 库。
在 Ubuntu 16.10 上 export ANDROID_EMULATOR_USE_SYSTEM_LIBS=1
必须添加到 $HOME/.profile
未知选项:-use-system-libs :(
@GregDan: 或/etc/environment
【参考方案2】:
$ cd Android/Sdk/emulator/lib64/libstdc++
$ mv libstdc++.so.6 libstdc++.so.6.bak
$ ln -s /usr/lib64/libstdc++.so.6
它对我有用
【讨论】:
看来我必须安装 libstdc++ 之后才能运行模拟器,谢谢您的帮助!
我的 libstdc++.so.6 位于 /usr/lib/x86_64-linux-gnu/libstdc++.so.6
@Joshua - 正确。对于 Ubuntu 17.10+,最后一步需要以下内容 $ ln -s /usr/lib/x86_64-linux-gnu/libstdc++.so.6
为我工作。不过我很想知道是什么破坏了它。
这个解决方案对我有用。从 Ubuntu 16.04 更新到 18.04 后,模拟器崩溃了。谢谢!【参考方案3】:
看看
https://code.google.com/p/android/issues/detail?id=197254
特别是项目#3 和#19。这是一种解决方法,而不是真正的解决方案,但它让我再次行动起来。您必须调整以下命令:
libstdc++.so.6
文件在您的系统上的位置 - 我使用 locate libstdc++.so.6
找到了这个
模拟器可执行文件的路径
您的模拟器的名称
所以我的命令是
LD_PRELOAD='/usr/lib/x86_64-linux-gnu/libstdc++.so.6' ~/Android/Sdk/tools/emulator -netdelay none -netspeed full -avd Nexus_5_API_21
这会启动模拟器,您可以在运行应用时在“设备选择器”对话框中选择它。
【讨论】:
谢谢!但在我的情况下,尽管我安装了 fglrx 包并且它工作正常,但操作系统没有看到它。但是在系统更新后,我得到了这个错误。我重新安装了这个包,它又开始工作了 :) 对不起英语。
链接中帖子 #23 中概述的修复允许我的模拟器在 Ubuntu 16.04 上启动,但模拟器屏幕仅显示黑色。
我用丑陋的方式解决了这个问题:cp /usr/lib/x86_64-linux-gnu/libstdc++.so.6 $ANDROID_HOME/tools/lib/libstdc++/libstdc++.so.6
如果有帮助,您可以找到模拟器的名称:LD_PRELOAD='/usr/lib/x86_64-linux-gnu/libstdc++.so.6' ~/Android/Sdk/tools/emulator -list-avds
【参考方案4】:
我在 Ubuntu 16.04 64 位中遇到了类似的错误。
对我来说,答案 #23 解决方案效果很好
https://code.google.com/p/android/issues/detail?can=2&start=0&num=100&q=&colspec=ID%20Status%20Priority%20Owner%20Summary%20Stars%20Reporter%20Opened&groupby=&sort=&id=197254
$ cd $ANDROID_HOME/android-sdk-linux_x86/tools/lib64/libstdc++
$ mv libstdc++.so.6 libstdc++.so.6.bak
$ ln -s /usr/lib64/libstdc++.so.6 $ANDROID_HOME/android-sdk-linux_x86/tools/lib64/libstdc++
【讨论】:
这对我有用。不过,您可能需要在不同的目录中查找您的 android sdk。我的发现是在/home/daniel/Android/Sdk/tools/lib64/libstdc++
是的,“/tools”之前的部分路径可以根据用户名和Sdk安装文件夹而有所不同。
确认工作,在ubuntu xenial中路径是/usr/lib/x86_64-linux-gnu/libstdc++.so.6
谢谢....这也是 ubuntu 16.10 中的解决方案,与上述评论 ln -s /usr/lib/x86_64-linux-gnu/libstdc++.so.6 中的路径相同~/Android/Sdk/tools/lib64/libstdc++【参考方案5】:
在 AVD 设置的 Emulated Performance Graphics 选项中使用“软件”。非常简单的解决方案。
【讨论】:
这很简单但是很慢:)
在 ubuntu 16 64bit 上工作,只需下拉选择 :) 10x
这是唯一对我有用的解决方案(Ubuntu 16.04LTS)【参考方案6】:
我这样做了,它正在工作
cd ~/Android/Sdk/emulator/lib64/libstdc++
mv libstdc++.so.6 libstdc++.so.6.bak
ln -s /usr/lib/x86_64-linux-gnu/libstdc++.so.6 libstdc++.so.6
【讨论】:
由于我的视频驱动程序,我遇到了这个错误,我后来重新安装了它,一切都开始工作了。我已经忘记了这个错误,很奇怪,有人在搜索包括这个主题在内的很多解决方案时仍然有问题。
我 10 分钟前刚遇到这个错误 :)【参考方案7】:
使用以下命令更好地定位您的系统默认 libstdc++.so.6
找到 libstdc++.so.6
然后在~/Android/Sdk/tools/lib64/libstdc++/中备份android sdk版本的文件
并为上述路径中的同名libstdc++.so.6创建一个软链接,替换现有的指向系统中默认文件的软链接
这样我们就不需要每次从命令行重新启动模拟器了。
【讨论】:
【参考方案8】:
尝试在模拟器设置中更改图形选项:
【讨论】:
【参考方案9】:
在我的机器上启动 AVD 时也遇到了很多问题。挣扎于使用系统库、创建到本地库的符号链接等......
真正让它对我有用的是安装 nvidia 驱动程序
sudo apt install nvidia-340
我的发行版(注意我没有使用 Ubuntu 15.10):
$ uname -a
Linux ruapehu 4.4.0-38-generic #57-Ubuntu SMP Tue Sep 6 15:42:33 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux
$ cat /etc/issue
Ubuntu 16.04.1 LTS \n \l
确保您检查了适合您的 nvidia 软件包,因为 Ubuntu 提供了不同的版本。例如:
$ sudo apt list "nvidia-[0-9][0-9][0-9]"
Listing... Done
nvidia-304/xenial 304.131-0ubuntu3 amd64
nvidia-331/xenial 340.96-0ubuntu3 amd64
nvidia-340/xenial,now 340.96-0ubuntu3 amd64 [installed]
nvidia-346/xenial 352.63-0ubuntu3 amd64
nvidia-352/xenial 361.42-0ubuntu2 amd64
nvidia-361/xenial,now 361.42-0ubuntu2 amd64
我以自下而上的策略测试了该列表,从 361 到我找到一个有效的(在我的例子中是 340)。
希望对您有所帮助。
【讨论】:
【参考方案10】:
在我的情况下(Ubuntu 16.10 64 位,Android Studio 2.3)库位于另一个地方。所以命令是:
/home/myusername/Android/Sdk/emulator/lib64/libstdc++
➜ libstdc++ ll
total 9,3M
-rwxr-xr-x 1 myusername myusername 4,6M мар 21 00:09 libstdc++.so.6
-rwxr-xr-x 1 myusername myusername 4,6M мар 21 00:09 libstdc++.so.6.0.18
➜ libstdc++ mv libstdc++.so.6 libstdc++.so.6.bak
➜ libstdc++ mv libstdc++.so.6.0.18 libstdc++.so.6.0.18.bak
➜ libstdc++ ln -s /usr/lib32/libstdc++.so.6 /home/myusername/Android/Sdk/emulator/lib64/libstdc++
➜ libstdc++ ln -s /usr/lib32/libstdc++.so.6.0.22 /home/myusername/Android/Sdk/emulator/lib64/libstdc++
➜ libstdc++ ll
total 9,3M
lrwxrwxrwx 1 myusername myusername 25 мар 29 13:18 libstdc++.so.6 -> /usr/lib32/libstdc++.so.6
-rwxr-xr-x 1 myusername myusername 4,6M мар 21 00:09 libstdc++.so.6.0.18.bak
lrwxrwxrwx 1 myusername myusername 30 мар 29 13:19 libstdc++.so.6.0.22 -> /usr/lib32/libstdc++.so.6.0.22
-rwxr-xr-x 1 myusername myusername 4,6M мар 21 00:09 libstdc++.so.6.bak
现在模拟器已经从 AVD 管理器正常启动了。
【讨论】:
【参考方案11】:
我在使用 i965_dri.so
和 swrast_dri.so
时遇到了类似的问题,我无法在 GUI 中更改为软件图形。
所以我去了模拟器的文件夹(Show on Disk
AVDM 中的链接)并找到了config.ini
这里我只是更改了以下行以阻止它使用 GPU:
hw.gpu.enabled=no
【讨论】:
【参考方案12】:
此问题已在 Android Emulator 27.2.9 中修复。请参阅此处列出的第一个修复程序:
https://developer.android.com/studio/releases/emulator#fixes
【讨论】:
【参考方案13】:
$ cd ~/Android/Sdk/emulator/lib64/libstdc++
$ mv libstdc++.so.6 libstdc++.so.6.bak
$ ln -s /usr/lib/x86_64-linux-gnu/libstdc++.so.6 libstdc++.so.6
【讨论】:
以上是关于Ubuntu 20.04编译AOSP 并启动模拟器的主要内容,如果未能解决你的问题,请参考以下文章
ubuntu 20.04 aosp 13/android s/android T/android12/android13 build
PX4模块设计之七:Ubuntu 20.04搭建Gazebo模拟器
PX4模块设计之八:Ubuntu 20.04搭建FlightGear模拟器