|
Fireprime Android5.1预置系统apk
发表于 2017-11-21 09:26:02
浏览:6904
|
回复:0
打印
只看该作者
[复制链接]
楼主
最近由于项目需要,要把apk预置到Android系统里,折腾了几天,终于搞定了,整理了下过程,欢迎指正错误
1.使用ADB安装测试:
adb root
adb remount
adb push xxx/xxx/my.apk /system/app/xxx/my.apk
adb shell
adb reboot
注意:debug版本可以直接安装,release版本必须签名
使用ADB安装测试没问题后,可以预置到Android源码里:
2.预置无源码apk到Android5.1:
创建vendor/custom/Preinstall/my/目录
创建vendor/custom/custom.mk
内容如下:
CUR_PATH := vendor/custom
include $(CUR_PATH)/Preinstall/Preinstall.mk
创建vendor/custom/Preinstall/Preinstall.mk
内容如下:
CUR_PATH := vendor/custom/Preinstall
include $(CUR_PATH)/my/my.mk
创建vendor/custom/Preinstall/my/my.mk
内容如下:
PRODUCT_PACKAGES += \
my
如果apk里有lib(.so文件),要把apk里的lib目录复制到vendor/custom/Preinstall/my/目录下
比如.so文件在my.apk的lib/armeabi/目录下,则vendor/custom/Preinstall/my/my.mk增加如下代码:
libs := $(shell ls $(CUR_PATH)/my/lib/armeabi/)
PRODUCT_COPY_FILES += $(foreach file, $(libs), \
$(CUR_PATH)/my/lib/armeabi/$(file):system/lib/$(file))
创建vendor/custom/Preinstall/my/Android.mk
内容如下:
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := my
LOCAL_MODULE_CLASS := APPS
LOCAL_MODULE_TAGS := optional
LOCAL_BUILT_MODULE_STEM := package.apk
LOCAL_MODULE_SUFFIX := $(COMMON_ANDROID_PACKAGE_SUFFIX)
#LOCAL_PRIVILEGED_MODULE := true
LOCAL_CERTIFICATE := PRESIGNED
#LOCAL_OVERRIDES_PACKAGES :=
LOCAL_SRC_FILES := $(LOCAL_MODULE).apk
#LOCAL_REQUIRED_MODULES :=
#LOCAL_PREBUILT_JNI_LIBS :=
include $(BUILD_PREBUILT)
把my.apk放到vendor/custom/Preinstall/my/下
重新编译,发现 out/target/product/rk312x/system/app/my目录下已经复制了my.apk
out/target/product/rk312x/system/lib目录下已经复制了.so文件
打包烧写,apk预置成功
|
|