AOSP自定义设备编译成功后模拟器黑屏故障求助(Android 6.0.1)
Hey there, let's troubleshoot that annoying black screen issue you're hitting after adding your custom device /device/my_company/my_product/ to Android 6.0.1_r46 Marshmallow. Since your default full-eng build works fine, the problem is almost certainly in your custom device configuration—let's break down the most likely culprits and fixes:
1. 检查BoardConfig.mk的核心硬件配置
This file is the backbone of your device setup, so double-check these critical flags:
- Kernel配置: If you're using the emulator's prebuilt kernel (which you should for emulated devices), make sure you have:
(Adjust the path to match your target architecture—x86_64, arm, etc.) Missing this or pointing to a mismatched kernel will cause the emulator to hang on boot.TARGET_PREBUILT_KERNEL := prebuilts/qemu-kernel/x86/kernel-qemu - CPU ABI匹配: Ensure
TARGET_CPU_ABIandTARGET_CPU_ABI2match the architecture you're building for. For example, the defaultfull-engbuild uses x86, so if your device is set toarmeabi-v7awithout proper emulator support, it'll fail to load. - 模拟器必需的硬件标识: Add these flags to enable emulator-specific hardware support:
BOARD_USES_QEMU_HARDWARE := true TARGET_USES_QEMU := true
2. 验证产品配置文件(my_product.mk/AndroidProducts.mk)
Your product needs to inherit emulator-specific configurations to load properly:
- 继承基础模拟器产品:
Without these, you'll miss critical emulator services like$(call inherit-product, $(SRC_TARGET_DIR)/product/emulator.mk) $(call inherit-product, $(SRC_TARGET_DIR)/product/core_minimal.mk)qemu-propswhich handle hardware parameter passing. - 检查
PRODUCT_PACKAGES:Make sure you include emulator-essential components:PRODUCT_PACKAGES += \ emulator-properties \ qemu-props \ libqemu_trace
3. 查看启动日志定位卡住的环节
A black screen doesn't mean nothing's happening—let's get logs:
- 启动模拟器时加内核日志参数:
This will print kernel boot logs directly to your terminal. Look for errors like "failed to mount rootfs" or missing driver modules.emulator -avd your_custom_avd -show-kernel - 如果能连接ADB(有时候即使黑屏ADB能连上),抓取系统日志:
Common red flags: SELinux denials, missing HALs, or system services crashing on startup.adb logcat -b all adb shell dmesg - 临时关闭SELinux测试:Add
androidboot.selinux=permissiveto your emulator's boot arguments. If the system loads, you need to fix your device's SELinux policy (add proper rules in/device/my_company/my_product/sepolicy/).
4. 检查自定义设备的Makefile语法
You mentioned a partial Android Mk snippet—make sure the device filtering logic is complete and correct:
ifneq ($(filter my_product, $(TARGET_DEVICE)),) # Your device-specific rules here endif
A missing closing endif or typo in TARGET_DEVICE can silently skip your device's configuration, leading to an incomplete build that boots to black screen.
5. 确认AVD配置正确性
- When creating your AVD, explicitly select your custom device (
my_product) instead of a generic one. - Verify the AVD's RAM allocation is at least 512MB (Marshmallow needs this minimum to boot properly).
- Ensure the AVD is using the system image from your custom build, not a leftover default image.
内容的提问来源于stack exchange,提问作者SK17




