I was trying to add an AOSPHost.apk described here in AOSP android12.1.0_r24 as system application. I am building emulator with lunch argument sdk_car_arm64-userdebug
. I have followed the procedure mentioned in the link, meaning:
aosp_root/packages/apps/CarAOSPHost/AOSPHost.apk
Android.mk
of AOSPHost.apk in /CarAOSPHost
LOCAL_PATH := $(my-dir)
################## Start of AOSPHost target ##################
include $(CLEAR_VARS)
LOCAL_MODULE := CarAOSPHost
LOCAL_LICENSE_KINDS := legacy_notice
LOCAL_LICENSE_CONDITIONS := notice
LOCAL_MODULE_OWNER := google
LOCAL_SRC_FILES := AOSPHost.apk
LOCAL_MODULE_CLASS := APPS
LOCAL_MODULE_TAGS := optional
LOCAL_MODULE_SUFFIX := $(COMMON_ANDROID_PACKAGE_SUFFIX)
LOCAL_BUILT_MODULE_STEM := package.apk
LOCAL_CERTIFICATE := PRESIGNED
LOCAL_PRIVILEGED_MODULE := true
LOCAL_PRODUCT_MODULE := true
LOCAL_DEX_PREOPT := false
include $(BUILD_PREBUILT)
<permissions>
<!-- Rename the package to com.android.car.templates.host -->
<privapp-permissions package="com.android.car.templates.host">
<!-- To be able to display activities in the cluster -->
<permission name="android.car.permission.CAR_DISPLAY_IN_CLUSTER" />
<!-- To be able to show navigation state (turn by turn directions) in the cluster.-->
<permission name="android.car.permission.CAR_NAVIGATION_MANAGER" />
<!-- To be considered a system-approved host -->
<permission name="android.car.permission.TEMPLATE_RENDERER" />
</privapp-permissions>
<!-- Declare support for templated applications. -->
<feature name="android.software.car.templates_host" />
</permissions>
Then I add PRODUCT_PACKAGES
in aosp-root/build/target/product/handheld_system.mk
: this was recommended in Stack Overflow
Also, I included PRODUCT_COPY_FILES
in aosp-root/build/target/product/handheld_system.mk
for permissions
PRODUCT_COPY_FILES += \
packages/apps/CarAOSPHost/com.android.car.templates.host.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/com.android.car.templates.host.xml
FAILED:
build/make/core/artifact_path_requirements.mk:26: warning: build/make/target/product/generic_system.mk produces files outside its artifact path requirement. Allowed paths are root/*, system/*
Offending entries:
product/priv-app/CarAOSPHost/CarAOSPHost.apk
In file included from build/make/core/main.mk:1342:
build/make/core/artifact_path_requirements.mk:26: error: Build failed.
11:24:21 ckati failed with: exit status 1
If it offends entries, how to add system app? or in which .mk file PRODUCT_PACKAGES
should be added?
After some research, I found that PRODUCT_PACKAGES should be declared here
/AOSP/packages/services/Car/car_product/build/car.mk