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/ccimx6sbc/ccimx6sbc.mk

  • device/digi/imx6/imx6.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 Calculator application makefile:

Calculator application makefile
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE_TAGS := optional
LOCAL_STATIC_JAVA_LIBRARIES := libarity android-support-v4 guava
LOCAL_SRC_FILES := $(call all-java-files-under, src)
LOCAL_SDK_VERSION := current
LOCAL_PACKAGE_NAME := Calculator
include $(BUILD_PACKAGE)
##################################################
include $(CLEAR_VARS)
LOCAL_PREBUILT_STATIC_JAVA_LIBRARIES := libarity:arity-2.1.2.jar
include $(BUILD_MULTI_PREBUILT)
# Use the following include to make our test apk.
include $(call all-makefiles-under,$(LOCAL_PATH))

Note that the LOCAL_PACKAGE_NAME of the Calculator application is Calculator. 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 Calculator application you need to remove the Calculator \ entry from the build/target/product/core.mk file. (It is not defined anywhere else.)

build/target/product/core.mk
[...]
PRODUCT_PACKAGES += \
    BasicDreams \
    Browser \
    Calculator \
    Calendar \
    CalendarProvider \
    CaptivePortalLogin \
[...]
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/ccimx6sbc/ccimx6sbc.mk file:

device/digi/ccimx6sbc/ccimx6sbc.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