Search code examples
androidandroid-source

How to build a system app in Android AOSP 13 for /system/ directory for emulator?


I want to build a sample system app which lives in the /system/app directory.

I am building AOSP Emulator using the goldfish device for the target product sdk_phone64_x86_64.

The standard process as per my knowledge was to get the application code to compile in AOSP environment first, using the Android.bp mechanism and then use PRODUCT_PACKAGES in a device.mk type file for the required target.

But this will cause build errors for artifact path requirement.

If I add the app name in 64bitonly/product/vendor.mk under device/generic/goldfish, and compile the systemimage using make, I get an error:

build/make/core/artifact_path_requirements.mk:30: warning:  device/generic/goldfish/64bitonly/product/sdk_phone64_x86_64.mk produces files inside build/make/target/product/generic_system.mks artifact path requirement.
Offending entries:
system/app/SampleSystemApp/SampleSystemApp.apk
In file included from build/make/core/main.mk:1352:
build/make/core/artifact_path_requirements.mk:30: error: Build failed.
16:08:03 ckati failed with: exit status 1

Later I did try Enforcing Product Partition Interfaces via this commit, but the same situation. So what is correct way to build an app in AOSP Android 13 environment which goes in /system partition?

Some examples include HTMLViewer, Keychain, etc.

However, I don't wish to modify build/make/target/product/handheld_system.mk

Is there a way to achieve this?


Note: Adding the module name to PRODUCT_PACKAGES in vendor.mk works fine on Android 10 AOSP.


Solution

  • So the actual solution is to utilise the flags

    PRODUCT_ARTIFACT_PATH_REQUIREMENT_ALLOWED_LIST+= \
        system/app/SampleSystemApp/%
    

    I added in my vendor.mk file and compiled the system image succesfully. However, Google suggests to use /system_ext instead. Overall, the best way IMO to bundle system apps is to directly use product or odm partitions as per requirement.