news 2026/5/25 18:09:22

编译Android 16 TV模拟器(一)

作者头像

张小明

前端开发工程师

1.2k 24
文章封面图
编译Android 16 TV模拟器(一)

1. 准备repo工具:

curl -L https://mirrors.tuna.tsinghua.edu.cn/git/git-repo > ~/bin/repo chmod a+x ~/bin/repo export REPO_URL='https://mirrors.tuna.tsinghua.edu.cn/git/git-repo'

2. 初始化仓库:

~/repo init -u https://mirrors.tuna.tsinghua.edu.cn/git/AOSP/platform/manifest -b android-16.0.0_r2

3. 同步代码:

~/repo sync -c -j8

4. 准备tv x86_64环境的 mk文件。代码里没有 x86_64的 mk,需要根据x86和其他x86_64的mk手动建立一个。

data/aosp/device/google/atv/products$ ls AndroidProducts.mk atv_logpersist.mk bootanimations aosp_tv_arm64.mk atv_lowram_defaults.mk gsi_tv_arm64.mk atv_mainline_system.mk gsi_tv_arm.mk aosp_tv_x86.mk atv_product.mk gsi_tv_base.mk atv_base.mk atv_system_ext.mk lowram_boot_profiles atv_emulator_vendor.mk atv_system.mk sdk_atv64_arm64.mk atv_generic_system.mk atv_vendor.mk sdk_atv_x86.mk

首先拷贝aosp_tv_x86.mk,重命名为aosp_tv_x86_64.mk,把其中 x86的配置改成 x86_64的。

$ cat aosp_tv_x86.mk # # Copyright (C) 2020 The Android Open Source Project # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # # Generate source.properties for image target PRODUCT_SDK_ADDON_SYS_IMG_SOURCE_PROP := \ device/google/atv/sdk/images_source.prop_template PRODUCT_USE_DYNAMIC_PARTITIONS := true # The system image of aosp_tv_x86-userdebug is a GSI for the devices with: # - x86 32 bits user space # - 64 bits binder interface # - VNDK enforcement # - compatible property override enabled # # All components inherited here go to system image # $(call inherit-product, device/google/atv/products/atv_generic_system.mk) # Enable mainline checking for excat this product name ifeq (aosp_tv_x86,$(TARGET_PRODUCT)) PRODUCT_ENFORCE_ARTIFACT_PATH_REQUIREMENTS := relaxed endif # # All components inherited here go to system_ext image # $(call inherit-product, device/google/atv/products/atv_system_ext.mk) # Packages required for ATV GSI PRODUCT_PACKAGES += \ TvProvision # # All components inherited here go to product image # $(call inherit-product, device/google/atv/products/atv_product.mk) # Default sound experience $(call inherit-product-if-exists, frameworks/base/data/sounds/AudioTv.mk) # Packages required for ATV GSI ifeq (aosp_tv_x86,$(TARGET_PRODUCT)) PRODUCT_PACKAGES += \ LeanbackIME \ TvSampleLeanbackLauncher endif # # All components inherited here go to vendor image # $(call inherit-product, device/google/atv/products/atv_emulator_vendor.mk) $(call inherit-product, device/generic/goldfish/board/emu64x/kernel_fstab_32.mk) $(call inherit-product, $(SRC_TARGET_DIR)/board/generic_x86/device.mk) ifeq (aosp_tv_x86,$(TARGET_PRODUCT)) $(call inherit-product, $(SRC_TARGET_DIR)/product/gsi_release.mk) endif PRODUCT_NAME := aosp_tv_x86 PRODUCT_DEVICE := generic_x86 PRODUCT_BRAND := Android PRODUCT_MODEL := AOSP TV on x86

修改之后的 aosp_tv_x86_64.mk:

cat aosp_tv_x86_64.mk # # Copyright (C) 2020 The Android Open Source Project # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # # Generate source.properties for image target PRODUCT_SDK_ADDON_SYS_IMG_SOURCE_PROP := \ device/google/atv/sdk/images_source.prop_template PRODUCT_USE_DYNAMIC_PARTITIONS := true # The system image of aosp_tv_x86-userdebug is a GSI for the devices with: # - x86 32 bits user space # - 64 bits binder interface # - VNDK enforcement # - compatible property override enabled # # All components inherited here go to system image # $(call inherit-product, device/google/atv/products/atv_generic_system.mk) # Enable mainline checking for excat this product name ifeq (aosp_tv_x86_64,$(TARGET_PRODUCT)) PRODUCT_ENFORCE_ARTIFACT_PATH_REQUIREMENTS := relaxed endif # # All components inherited here go to system_ext image # $(call inherit-product, device/google/atv/products/atv_system_ext.mk) # Packages required for ATV GSI PRODUCT_PACKAGES += \ TvProvision # # All components inherited here go to product image # $(call inherit-product, device/google/atv/products/atv_product.mk) # Default sound experience $(call inherit-product-if-exists, frameworks/base/data/sounds/AudioTv.mk) # Packages required for ATV GSI ifeq (aosp_tv_x86_64,$(TARGET_PRODUCT)) PRODUCT_PACKAGES += \ LeanbackIME \ TvSampleLeanbackLauncher endif # # All components inherited here go to vendor image # $(call inherit-product, device/google/atv/products/atv_emulator_vendor.mk) $(call inherit-product, device/generic/goldfish/board/emu64x/kernel_fstab_32.mk) $(call inherit-product, $(SRC_TARGET_DIR)/board/generic_x86_64/device.mk) ifeq (aosp_tv_x86_64,$(TARGET_PRODUCT)) $(call inherit-product, $(SRC_TARGET_DIR)/product/gsi_release.mk) endif TARGET_ARCH := x86_64 TARGET_ARCH_VARIANT := x86_64 TARGET_CPU_ABI := x86_64 TARGET_SUPPORTS_64_BIT_APPS := true PRODUCT_NAME := aosp_tv_x86_64 PRODUCT_DEVICE := generic_x86_64 PRODUCT_BRAND := Android PRODUCT_MODEL := AOSP TV on x86_64

然后把

$(LOCAL_DIR)/aosp_tv_x86_64.mk 加到 AndroidProducts.mk里面。

5. 准备编译目标

source build/envsetup.sh lunch aosp_tv_x86_64-aosp_current-eng

如果没有问题,会输出如下:

$ lunch aosp_tv_x86_64-aosp_current-eng 00:39:36 Build sandboxing disabled due to nsjail error. ============================================ PLATFORM_VERSION_CODENAME=REL PLATFORM_VERSION=16 TARGET_PRODUCT=aosp_tv_x86_64 TARGET_BUILD_VARIANT=eng TARGET_ARCH=x86_64 TARGET_ARCH_VARIANT=x86_64 TARGET_2ND_ARCH=x86 TARGET_2ND_ARCH_VARIANT=x86_64 HOST_OS=linux HOST_OS_EXTRA=Linux-6.8.0-88-generic-x86_64-Ubuntu-24.04.3-LTS HOST_CROSS_OS=windows BUILD_ID=BP2A.250605.031.A3 OUT_DIR=out SOONG_ONLY=false ============================================ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Wondering whether to use user, userdebug or eng? user The builds that ship to users. Reduced debugability. userdebug High fidelity to user builds but with some debugging options enabled. Best suited for performance testing or day-to-day use with debugging enabled. eng More debugging options enabled and faster build times, but runtime performance tradeoffs. Best suited for day-to-day local development when not doing performance testing. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

如果没有改好,可能会输出如下:

lunch aosp_tv_x86_64-aosp-eng 23:22:01 Build sandboxing disabled due to nsjail error. In file included from build/make/core/config.mk:422: In file included from build/make/core/envsetup.mk:368: build/make/core/board_config.mk:334: error: Building a 32-bit-app-only product on a 64-bit device. If this is intentional, set TARGET_SUPPORTS_64_BIT_APPS := false. 23:22:01 dumpvars failed with: exit status 1 panic: dumpvars failed with: exit status 1

参考:

https://mirrors.tuna.tsinghua.edu.cn/help/AOSP/

版权声明: 本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若内容造成侵权/违法违规/事实不符,请联系邮箱:809451989@qq.com进行投诉反馈,一经查实,立即删除!
网站建设 2026/5/26 6:46:16

Kubernetes Master 节点核心组件全景解析

Kubernetes Master 节点核心组件全景解析 引言 在 Kubernetes 集群中,Master 节点是“大脑”和“控制中心”,负责整个集群的管理、调度、监控与期望状态的维护。 相对而言,**工作节点(Node)**负责运行实际的应用容器。 Master 节点核心组件主要包括: kube-apiserver e…

作者头像 李华
网站建设 2026/5/26 6:47:03

SolidWorks异形孔向导功能介绍

SolidWorks 的 异形孔向导(Hole Wizard)​ 是其最核心的特征工具之一,主要用于快速创建符合国际标准(如 ISO、ANSI、GB 等)的标准化孔特征(如螺纹孔、沉头孔、锥孔、阶梯孔等)。它通过参数化设计…

作者头像 李华
网站建设 2026/5/25 21:22:04

数据大国的存储短板:600亿HDD依赖如何突围?

“HDD(机械硬盘),是我们IT产业链里唯一还没拿下的核心件。”华为高级副总裁、华为云CEO兼数据存储产品线总裁周跃峰的这番言论,近期在存储行业引发广泛共鸣。在AI扩容、云上增算成为行业热点的当下,这个看似“老掉牙”的存储设备,突然成为悬在中国存储产业头顶的“达摩克…

作者头像 李华
网站建设 2026/5/25 9:05:34

零延迟英雄锁定:League Akari智能选人系统深度解析

还在为手慢抢不到心仪英雄而懊恼?每次选人阶段都像在和时间赛跑?League Akari的智能选人系统正是为解决这一痛点而生。在/src/main/modules/auto-select/中的核心算法,能够在毫秒级内完成英雄锁定,让你在选人阶段占据绝对优势。 【…

作者头像 李华
网站建设 2026/5/26 7:14:03

哔哩下载姬:5个实用技巧让你的B站视频下载效率翻倍

哔哩下载姬:5个实用技巧让你的B站视频下载效率翻倍 【免费下载链接】downkyi 哔哩下载姬downkyi,哔哩哔哩网站视频下载工具,支持批量下载,支持8K、HDR、杜比视界,提供工具箱(音视频提取、去水印等&#xff…

作者头像 李华
网站建设 2026/5/25 11:02:56

腾讯优图实验室开源Youtu-Embedding文本表示模型,赋能企业级AI应用创新

10月14日,腾讯优图实验室宣布正式对外发布Youtu-Embedding文本表示模型的源代码。作为一款专为企业级应用场景打造的通用型文本处理工具,该模型凭借其卓越的语义理解能力和广泛的场景适配性,正在成为企业数字化转型进程中的关键技术支撑。据腾…

作者头像 李华