新建apk目录(apk为名)-->放入apk和Android.mk文件
Android.mk作用主要是解压apk包将lib库文件解压到 system/lib或system/lib64包下,拷贝到system/app或system/pri-app/ 下
第一种方式 Android.mk通过shell命令 mkdir -p 创建对应的文件夹,shell cp命令拷贝到对应的system/app或system/priv-app:
include $(CLEAR_VARS)
LOCAL_MODULE := TestDemo
$(shell mkdir -p $(PRODUCT_OUT)/system/priv-app/TestDemo)
$(shell cp $(LOCAL_PATH)/$(LOCAL_MODULE).apk $(PRODUCT_OUT)/system/priv-app/TestDemo/)
第二种方式:如果apk文件中有依赖的so文件库,可以解压将其拷贝到系统system/lib和system/lib64
Android.mk的内容主要就是解压拷贝:
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := TestDemo
LOCAL_MODULE_CLASS := APPS
LOCAL_CERTIFICATE := PRESIGNED
LOCAL_MODULE_TAGS := optional
LOCAL_SRC_FILES := TestDemo.apk #源文件
LOCAL_MODULE_SUFFIX := $(COMMON_ANDROID_PACKAGE_SUFFIX)
LOCAL_POST_INSTALL_CMD := $(hide) UNZIP_PATH=$(LOCAL_PATH)/$(LOCAL_MODULE)\
unzip -o $(LOCAL_PATH)/$(LOCAL_SRC_FILES) -d $$UNZIP_PATH\
mv $$UNZIP_PATH/lib/armeabi-v7a/ $$UNZIP_PATH/lib/arm\
mv $$UNZIP_PATH/lib $(TARGET_OUT)/app/$(LOCAL_MODULE)/lib\伍缺老
rm $$UNZIP_PATH -rf
include $(BUILD_PREBUILT)
相同的方式建立文件夹,脚本文件和Android.mk文件:
Android.mk内容:
include $(CLEAR_VARS)
LOCAL_MODULE := test.sh #脚本名称
LOCAL_MODULE_TAGS := optional
LOCAL_MODULE_PATH := $(TARGET_OUT)/bin #编译后生腔升成位置
LOCAL_SRC_FILES := $(LOCAL_MODULE) #源码文件
LOCAL_MODULE_CLASS := FAKE
如/vendor/companyname/mycompany.mk
PRODUCT_PACKAGES := \
PrebuiltGmsCore \
GmsCoreSetupPrebuilt \
扮陪 GoogleServicesFramework \
GoogleLoginService \
Phonesky \
libDPN_SECURITY \
test.sh \ #加入
然后在device/目录下找到本工mk文件,例如:device/softwinner/mycompany/mycompany.mk
加入
$(call inherit-product,vendor/companyname/mycompany.mk) #这样系统就可以找到这个mycompany.mk文件,将这些申明的apk编译进系统
LOCAL_PATH:= $(call my-dir)include $(CLEAR_VARS)
# files that live under /system/etc/...
copy_from := \闹尘
etc/dbus.conf \
etc/hosts
ifeq ($(TARGET_PRODUCT),generic)
copy_from += etc/vold.conf
endif
# the /system/etc/init.goldfish.sh is needed to enable emulator support
# in the system image. In theory, we don't need these for -user builds
# which are device-specific. However, these builds require at the moment
# to run the dex pre-optimization *in* the emulator. So keep the file until
# we are capable of running dex preopt on the host.
#
copy_from += etc/薯陆init.goldfish.sh
copy_to := $(addprefix $(TARGET_OUT)/,$(copy_from))
copy_from := $(addprefix $(LOCAL_PATH)/,$(copy_from))
$(copy_to) : PRIVATE_MODULE := system_etcdir
$(copy_to) : $(TARGET_OUT)/% : $(LOCAL_PATH)/% | $(ACP)
$(transform-prebuilt-to-target)
ALL_PREBUILT += $(copy_to)
上数弯顷面的参考
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)