[RK3399] [android 7.1.2]添加预装应用

一.整体思路

将预装的apk拷贝到相应device/rockchip/rk33xx/preinstall 目录中,编译,刷机,预装应用自动安装

二.详细过程

1.platform确定

device/rockchip/common/device.mk中有:

# Prebuild apps
ifneq ($(strip $(TARGET_PRODUCT)), )
    TARGET_DEVICE_DIR=$(shell test -d device && find device -maxdepth 4 -path '*/$(TARGET_PRODUCT)/BoardConfig.mk')
    TARGET_DEVICE_DIR := $(patsubst %/,%,$(dir $(TARGET_DEVICE_DIR)))
    $(shell python $(LOCAL_PATH)/auto_generator.py $(TARGET_BOARD_PLATFORM) preinstall bundled_persist-app)
    $(shell python $(LOCAL_PATH)/auto_generator.py $(TARGET_BOARD_PLATFORM) preinstall_del bundled_uninstall_back-app)
    $(shell python $(LOCAL_PATH)/auto_generator.py $(TARGET_BOARD_PLATFORM) preinstall_del_forever bundled_uninstall_gone-app)
    -include device/rockchip/$(TARGET_BOARD_PLATFORM)/preinstall/preinstall.mk
    -include device/rockchip/$(TARGET_BOARD_PLATFORM)/preinstall_del/preinstall.mk
    -include device/rockchip/$(TARGET_BOARD_PLATFORM)/preinstall_del_forever/preinstall.mk
endif

根据TARGET_BOARD_PLATFORM找到所在目录,device/rockchip/rk3399/

2.目录确定

根据device/rockchip/rk3399/preinstall或preinstall_del等/README.txt ,选择你对应拷贝的apk

auto_generator.py会在编译过程中,将拷贝的apk解包,自动生成编译mk文件

3.编译、烧录

4.安装流程

PackageManagerService服务启动过程中

 scanDirTracedLI(Environment.getPrebundledUninstallBackDirectory(),
                    mDefParseFlags | PackageParser.PARSE_IS_PREBUNDLED_DIR,
                    scanFlags,0);

扫描安装目录,完成安装。

三.排坑记录

实践中,部分应用安装失败,将实际生成文件直接adb install 提示错误:

INSTALL_PARSE_FAILED_NO_CERTIFICATES: Failed to collect certificates from /data/app/vmdl562396072.tmp/base.apk is signed using APK Signature Scheme v2, but no such signature was found. Signature stripped?]

对APK 编译过程中有Signature Scheme v2标识的,即使我们预安装mk中对签名使用prebuild属性,apk无法通过签名校验过程

解决方案:1.去掉Scheme v2标识,重新编译

2.device.mk中,直接使用拷贝命令
PRODUCT_COPY_FILES += \
    $(LOCAL_PATH)/wz/apk/com.lajiao.video.apk:system/vendor/bundled_uninstall_back-app/com.lajiao.video/com.lajiao.video.apk \
    $(LOCAL_PATH)/wz/apk/com.shentong.medlive.apk:system/vendor/bundled_uninstall_back-app/com.shentong.medlive/com.shentong.medlive.apk \
    $(LOCAL_PATH)/wz/apk/hdpfans.com.apk:system/vendor/bundled_uninstall_back-app/hdpfans.com/hdpfans.com.apk

 

参考链接:

https://blog.csdn.net/kris_fei/article/details/78582665

https://blog.csdn.net/nwpushuai/article/details/79319651

https://blog.csdn.net/joye123/article/details/52788481

你可能感兴趣的:(android编译)