Intro
Sometimes we need to add some pre-built apk in our build because the source isn’t available or it is more easy to just pull the binaries from, and add it to our build. This post says how to do it.
Implementation
Suppose that we have our vendor as CUSTOM_VENDOR
-
In
vendor/CUSTOM_VENDOR/prebuilt/app
, create a folder namedMyCoolApp
. -
In
MyCoolApp
folder, add the apkMyCoolApp.apk
and aAndroid.mk
vendor/
├─ CUSTOM_VENDOR/
├─config/
│ └─common.mk
└─prebuilt/
└─app/
└─MyCoolApp/
├─MyCoolApp.apk
└─Android.mk
Android.mk
file which contains the following instructions
Android.mk
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE_TAGS := optional
LOCAL_MODULE := Testapk
LOCAL_SRC_FILES := $(LOCAL_MODULE).apk
LOCAL_MODULE_CLASS := APPS
LOCAL_CERTIFICATE := PRESIGNED
# LOCAL_PRIVILEGED_MODULE = true
# LOCAL_MODULE_PATH := $(TARGET_OUT_DATA)
# LOCAL_OVERRIDES_PACKAGES := Home Launcher2 Launcher3
LOCAL_MODULE_SUFFIX := $(COMMON_ANDROID_PACKAGE_SUFFIX)
include $(BUILD_PREBUILT)
- That’s it ! Add following instruction with respected device/vendor.
PRODUCT_PACKAGES +=\
MyCoolApp
Notes:
-
If your APK is already not signed, use the
u wat to use for signing as value for LOCAL_CERTIFICATE LOCAL_CERTIFICATE can have following values
- PLATFORM or
- PRESIGNED or
- <KEY>
-
If you want it as system app use
LOCAL_PRIVILEGED_MODULE = true
-
If you want your APK to end up in the
/data/app/
directory, add the lineLOCAL_MODULE_PATH := $(TARGET_OUT_DATA)
-
If you want to Override some packages, use
LOCAL_OVERRIDES_PACKAGES := Home Launcher3 <package name>