2018-06-12 add your apk

【转】Android将第三方apk文件编译生成到system.img中

1. Android.mk

LOCAL_PATH := $(call my-dir)

include $(CLEAR_VARS)

LOCAL_MODULE_TAGS := optional
#apk名字
LOCAL_PACKAGE_NAME := AICXY
LOCAL_SRC_FILES := $(call all-subdir-java-files)

# 1. system/app
#系统签名
LOCAL_CERTIFICATE := platform
#LOCAL_CERTIFICATE := PRESIGNED

# 2. system/priv-app
#LOCAL_PRIVILEGED_MODULE := true


include $(BUILD_PACKAGE)
# build your apk
include $(call all-makefiles-under,$(LOCAL_PATH))

# not work?
#LOCAL_POST_PROCESS_COMMAND := $(shell cp -r $(LOCAL_PATH)/*.apk $(TARGET_OUT)/app/)
#LOCAL_BUILT_MODULE_STEM := package.apk

2. build your apk

include $(call all-makefiles-under,$(LOCAL_PATH))

在自己源码的packages\apps\路径下,新建test文件夹,然后将要添加的第三方app拷贝到该文件夹下,在test/下新建android.mk文件,内容如下:

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

LOCAL_POST_PROCESS_COMMAND := $(shell mkdir $(TARGET_OUT)/app/test/)
LOCAL_POST_PROCESS_COMMAND := $(shell cp -r $(LOCAL_PATH)/*.apk $(TARGET_OUT)/app/test/)

然后编辑build/target/product/core.mk文件,将该apk的名字加入到PRODUCT_PACKAGES中,之后执行make编译后会在out/目录下的system/目录发现生成了test/文件夹,文件夹的内容即为test.apk,重新烧录程序到机器中即可发现添加的apk已经合入system.img中。

3. System.img

source build/envsetup.sh
lunch 19
make snod

你可能感兴趣的:(2018-06-12 add your apk)