One of the most common customization actions to perform in Android firmware is to establish the default applications and libraries that will be compiled and included in the final Android image. These items are defined in the PRODUCT_PACKAGES variable that is declared and extended in several Android makefiles in the sources. This is a brief list of makefiles containing the most important applications and libraries that will be included in the final Android firmware:

  • device/digi/imx8q/ccimx8xsbcpro/ccimx8xsbcpro.mk

  • device/digi/imx8q/ProductConfigCommon.mk

  • build/target/product/generic.mk

  • build/target/product/generic_no_telephony.mk

  • build/target/product/telephony.mk

  • build/target/product/core.mk

  • build/target/product/core_base.mk

  • build/target/product/core_minimal.mk

  • build/target/product/base.mk

  • build/target/product/embedded.mk

The makefiles of the list are sorted by calling order, from product specific to Android core.

Each application or library is identified by its LOCAL_PACKAGE_NAME, which defined in the component makefile. This is an example of the ExactCalculator application makefile:

ExactCalculator application makefile
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)

LOCAL_RESOURCE_DIR := $(LOCAL_PATH)/res
LOCAL_USE_AAPT2 := true

LOCAL_MODULE_TAGS := optional
LOCAL_SDK_VERSION := current

LOCAL_PACKAGE_NAME := ExactCalculator
LOCAL_OVERRIDES_PACKAGES := Calculator

LOCAL_SRC_FILES := $(call all-java-files-under, src)

LOCAL_PROGUARD_FLAG_FILES := proguard.flags

LOCAL_STATIC_JAVA_LIBRARIES := cr
LOCAL_STATIC_ANDROID_LIBRARIES += androidx.legacy_legacy-support-v4
LOCAL_STATIC_ANDROID_LIBRARIES += androidx.gridlayout_gridlayout
LOCAL_STATIC_ANDROID_LIBRARIES += androidx.recyclerview_recyclerview

include $(BUILD_PACKAGE)

Note that the LOCAL_PACKAGE_NAME of the ExactCalculator application is ExactCalculator. This will identify the component in all Android sources.

Remove a default application or library

To remove a default application or library from your custom Android firmware, you must delete all the entries of that component from the PRODUCT_PACKAGES variable. To do so, look for the component identifier in the list of makefiles presented before and remove all the entries you find.

The same application or library could be declared in more than one makefile. Digi recommends you check the list of makefiles listed before to ensure that the component is fully removed.

For example, to remove the ExactCalculator application you need to remove the ExacCalculator \ entry from the build/target/product/core.mk file. (It is not defined anywhere else.)

build/target/product/core.mk
[...]
PRODUCT_PACKAGES += \
    BasicDreams \
    BlockedNumberProvider \
    [...]
    DownloadProviderUi \
    Email \
    ExactCalculator \
    ExternalStorageProvider \
    FusedLocation \
[...]
Removing applications or libraries may cause other Android components to stop working properly. Do so carefully.

It is highly recommended that you clean the exported components before attempting a new product build in order to apply the changes. To do so, issue this command in the root of your Android sources:

$  make installclean

Add a default application or library

To add a default Android application or library to your custom Android firmware, you need to add the component identifier to the PRODUCT_PACKAGES variable. You can do that in any of the makefiles listed before, but it is highly recommended that you add it to the product-specific makefile to track all the new components there.

For example, if you have an Android application whose LOCAL_PACKAGE_NAME defined in its makefile is MyApplication, you only need to add that entry to the PRODUCT_PACKAGES variable in the device/digi/imx8q/ccimx8xsbcpro/ccimx8xsbcpro.mk file:

device/digi/imx8q/ccimx8xsbcpro/ccimx8xsbcpro.mk
[...]
# Your custom applications
PRODUCT_PACKAGES += \
    MyApplication
[...]

It is highly recommended that you clean the exported components before attempting a new product build in order to apply the changes. To do so, issue this command in the root of your Android sources:

$  make installclean