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/imx8m/ccimx8mmdvk/ccimx8mmdvk.mk

  • device/digi/imx8m/ProductConfigCommon.mk

  • build/target/product/generic.mk

  • build/target/product/generic_no_telephony.mk

  • build/target/product/handheld_system.mk

  • build/target/product/media_system.mk

  • build/target/product/base_system.mk

  • build/target/product/handheld_system_ext.mk

  • build/target/product/media_system_ext.mk

  • build/target/product/base_system_ext.mk

  • build/target/product/handheld_vendor.mk

  • build/target/product/media_vendor.mk

  • build/target/product/base_vendor.mk

  • build/target/product/handheld_product.mk

  • build/target/product/media_product.mk

  • build/target/product/base_product.mk

  • build/target/product/telephony.mk

  • build/target/product/telephony_system.mk

  • build/target/product/telephony_system_ext.mk

  • build/target/product/telephony_vendor.mk

  • build/target/product/telephony_product.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:

  • name in the component Android.bp file

  • or LOCAL_PACKAGE_NAME in the component Android.mk file

This is an example of the Gallery2 application Android.bp file:

Gallery2 Android.bp
android_app {
    name: "Gallery2",

    static_libs: [
        "androidx.fragment_fragment",
        "androidx.legacy_legacy-support-core-ui",
        "androidx.core_core",
        "androidx.legacy_legacy-support-v13",
        "com.android.gallery3d.common2",
        "xmp_toolkit",
        "mp4parser",
    ],

    srcs: [
        "src/**/*.java",
        "src_pd/**/*.java",
    ],

    resource_dirs: ["res"],

    product_specific: true,

    overrides: [
        "Gallery",
        "Gallery3D",
        "GalleryNew3D",
    ],

    sdk_version: "current",

    jni_libs: [
        "libjni_eglfence",
        "libjni_filtershow_filters",
        "libjni_jpegstream",
    ],

    optimize: {
        proguard_flags_files: ["proguard.flags"],
    },

    libs: ["org.apache.http.legacy"],

    jarjar_rules: "jarjar-rules.txt",
}

Note that the name of the Gallery2 application is Gallery2. This will identify the component in all Android sources.

For more information about Android build system, see https://source.android.com/setup/build

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

build/target/product/handheld_product.mk
[...]
PRODUCT_PACKAGES += \
    Browser2 \
    Calendar \
    [...]
    Gallery2 \
    LatinIME \
    Music \
    [...]
    frameworks-base-overlays
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 identified as MyApplication (name in its Android.bp file or LOCAL_PACKAGE_NAME in its Android.mk file), you only need to add that entry to the PRODUCT_PACKAGES variable in the device/digi/imx8m/ccimx8mmdvk/ccimx8mmdvk.mk file:

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