1. Pre-install the sourceless APK and its dependent libraries into the system, this apk can be upgraded
++++++++++++++++++++++++++++++
1. Pre-install the sourceless APK and its dependent libraries into the system, this apk can be upgraded
---------- cut here ------------------ LOCAL_PATH := $(call my-dir) #Preset aliuyi.apk include $(CLEAR_VARS) LOCAL_MODULE := wwwa.apk LOCAL_SRC_FILES := aliuyi.apk LOCAL_MODULE_TAGS := optional LOCAL_MODULE_CLASS := APPS LOCAL_CERTIFICATE := PRESIGNED LOCAL_MODULE_PATH := $(TARGET_OUT)/app include $(BUILD_PREBUILT) #Method 1: Preset resource files such as so include $(CLEAR_VARS) LOCAL_MODULE := wanghai.so LOCAL_SRC_FILES := wanghai.so LOCAL_MODULE_TAGS := optional LOCAL_MODULE_CLASS := SHARED_LIBRARIES LOCAL_MODULE_PATH := $(TARGET_OUT)/lib/ include $(BUILD_PREBUILT) #Method 2: Preset resource files such as so
include $(CLEAR_VARS) LOCAL_MODULE_TAGS := optional LOCAL_PREBUILT_LIBS := sdfapk.so sdffff.so include $(BUILD_MULTI_PREBUILT)
#Method three:
Preset resource files such as so, and add such a sentence in Android.mk. Note: If the path does not exist in this way, the execution of this command will fail, but no error will be reported!$( shell cp -rf $(LOCAL_PATH)/libs/*.so $(TARGET_OUT)/lib)
---------- cut here ------------------explain:
LOCAL_MODULE specifies the name (full name) of the copied apk. There can be a path in this variable,but the path will also be copied and created. If you are compiling the entire android source code, this apk must have been added to the PRODUCT_PACKAGES variable, otherwise it will not be will be copied to the corresponding location,
LOCAL_MODULE_PATH specifies the path to copy, if the path does not exist, create it yourself
LOCAL_SRC_FILES specifies the source apk
LOCAL_CERTIFICATE := PRESIGNED indicates that the apk has been signed, and the system does not need to sign again;
LOCAL_MODULE_CLASS 指定文件类型,apk文件用APPS, 并且 会检查 是否是apk文件,动态库so文件用SHARED_LIBRARIES ,bin文件用EXECUTABLES,其他文件 用ETC
注意:若是被预置的apk里有so库,需要将从Test.apk的 so库拷贝到 out/target/product/xxx/system/lib/目录下,若无 so 库,则去掉此步;
方法一 只能针对 一个文件,方法二 可以 针对多个文件,但 只能 把 文件 拷贝到 system/lib/ 下,
Android提供了Prebuilt编译方法,两个文件prebuilt.mk和multi_prebuilt.mk,对应的方法宏是BUILD_PREBUILT和 BUILD_MULTI_PREBUILT。
prebuilt.mk就是prebuilt的具体实现,它是针对独立一个文件的操作,multi_prebuilt.mk 可以针对多个文件的,它对多个文件进行判断,然后调用prebuilt对独立一个文件进行处理。