An Android.mk file to add an .apk to /system/priv-app


I am building the Android Open Source Project (AOSP) from source for the Pine 64 board using the community v6 version.  One of the things I needed to do was add a pre-compiled .apk file to the /system/priv-app folder.  Finding information on how to create an Android.mk file to do that was really difficult.  Below is the Android.mk file that I finally came up with.

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

# Module name should match apk name to be installed (without the .apk extension)
LOCAL_MODULE := MyModule
LOCAL_SRC_FILES := $(LOCAL_MODULE).apk
LOCAL_MODULE_CLASS := APPS
LOCAL_MODULE_SUFFIX := $(COMMON_ANDROID_PACKAGE_SUFFIX)

LOCAL_PACKAGE_NAME := MyModule
LOCAL_CERTIFICATE := shared
LOCAL_PRIVILEGED_MODULE := true

# If its a launcher / home App (which mine is) and you want to replace the other launchers (which I do)
LOCAL_OVERRIDES_PACKAGES := Home GoogleHome Launcher Launcher2 Launcher3

# The priv-app folder

TARGET_OUT_DATA_APPS_PRIVILEGED := $(TARGET_OUT_DATA)/priv-app

include $(BUILD_PREBUILT)


Leave a comment