You need to enable JavaScript to run this app.
最新活动
大模型
产品
解决方案
定价
生态与合作
支持与服务
开发者
了解我们

AOSP自定义设备编译成功后模拟器黑屏故障求助(Android 6.0.1)

解决AOSP自定义设备编译成功但模拟器黑屏的问题

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:
    TARGET_PREBUILT_KERNEL := prebuilts/qemu-kernel/x86/kernel-qemu
    
    (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.
  • CPU ABI匹配: Ensure TARGET_CPU_ABI and TARGET_CPU_ABI2 match the architecture you're building for. For example, the default full-eng build uses x86, so if your device is set to armeabi-v7a without 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:

  • 继承基础模拟器产品:
    $(call inherit-product, $(SRC_TARGET_DIR)/product/emulator.mk)
    $(call inherit-product, $(SRC_TARGET_DIR)/product/core_minimal.mk)
    
    Without these, you'll miss critical emulator services like qemu-props which 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:

  • 启动模拟器时加内核日志参数:
    emulator -avd your_custom_avd -show-kernel
    
    This will print kernel boot logs directly to your terminal. Look for errors like "failed to mount rootfs" or missing driver modules.
  • 如果能连接ADB(有时候即使黑屏ADB能连上),抓取系统日志:
    adb logcat -b all
    adb shell dmesg
    
    Common red flags: SELinux denials, missing HALs, or system services crashing on startup.
  • 临时关闭SELinux测试:Add androidboot.selinux=permissive to 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

火山引擎 最新活动