OpenHarmony 源码中编译Hap包预装(L2) 原创
目录
1. 简介
本文介绍 OpenHarmony3.2 beta3 Stage工程,系统源码中编译js,并预装到系统中的配置。
2. 源码路径applications\standard\MyApplication
(stage工程)
源码见附件,签名参考签名
2.1 源码修改
2.1.1 修改applications\standard\MyApplication\AppScope\app.json
不添加version信息,编译的hap包安装报错:failed to install bundle. error: install parse profile missing prop.
2.1.2 新建module.json
applications\standard\MyApplication\entry\src\main\module.json5
复制一份并将复制文件重命名为module.json
如果module.json中添加权限,需要对应调整UnsgnedReleasedProfileTemplate-sys2.0.json中的"allowed-acls"
字段,重新生成签名。
2.1.3 修改applications\standard\hap\ohos.build
在"module_list"
中添加"//applications/standard/MyApplication:myapplication_hap"
2.2 添加文件
2.2.1 添加文件BUILD.gn
路径:applications\standard\MyApplication\BUILD.gn
内容:
2.2.2 签名文件
签名文件app-profile-20-sys.p7b在applications\standard\MyApplication\signature\app-profile-20-sys.p7b
, 自己可以参考文档生成,签名不对有可能预装不成功
, 签名使用的是OpenHarmony默认的别名和密.码。
2.3 编译
全量编译: ./build.sh --product-name rk3568
后就会生成myapplication.hap包,可以通过hdc_std.exe install myapplication.hap安装
2.4 预装
2.4.1 OpenHarmony 3.2beta2(已经废弃)
直接编译好后,重新烧写系统即可。
2.4.2 OpenHarmony 3.2beta3
经过如下配置之后,重新编译烧写系统,应用即可预装
2.4.2.1 使用keytool输出指纹(keytool是java自带工具)
keytool -printcert -file OpenHarmonyProfileRelease.pem
选择第一条指纹SHA256的数据,去掉中间的冒号,我的版本去掉冒号后的指纹为(有说任何一条sha256都可以):
"9AED2A79925ECA050CD2BB9D2A7F694E49E5E135D28EBDCE53836DE76B5080ED"
2.4.2.2 配置vendor\hihope\rk3568\preinstall-config\install_list_capability.json
2.4.2.3 配置vendor\hihope\rk3568\preinstall-config\install_list.json
removable字段,表示预装应用是否可以卸载。
FA工程正确编译成hap包未解决。
3. 问题
-
Stage工程可以编译,编译结果还能安装成功。FA工程编译成功了,不能安装,安装报错:failed to install bundle. error: install parse profile missing prop.
-
**failed to install bundle. error: install state error. **
重新烧系统
-
Stage工程可以编译hap包安装报错:failed to install bundle. error: install parse profile missing prop.
app.json
没有添加version配置 -
failed to install bundle. error: install failed due to grant request permissions failed
module.json
中配置了权限,需要对应调整UnsgnedReleasedProfileTemplate-sys2.0.json中的"allowed-acls"
字段,重新生成签名并导入工程,重新编译。
大佬最近非常活跃呀!
学习并收藏了,谢谢分享