注意:需要使用安装python3
加固包生成流程
- 使用gradlew assembleRelease生成 build/outputs/apk/release/DDMobileApp-release.apk
- 上传release包到aws(这一步是为了生成一个url给乐固下载待加固的apk,也可以使用其它方法)
- 使用乐固api创建加固任务
- 轮询加固状态
- 下载加固后的apk
- 重新签名并生成渠道包
主流程代码
def main(build_release):
if build_release != "not_build_release":
assemble_release()
upload_apk_to_aws()
shield_resp = create_shield()
has_item_id = "ItemId" in shield_resp["Response"]
if not has_item_id:
error_exit("error: ItemId not found")
return
item_id = shield_resp["Response"]["ItemId"]
time.sleep(10)
apk_download_url = query_download_url(item_id)
download_file(apk_download_url)
bash("清理命令")
# 运行渠道包脚本
bash("替换成渠道包脚本"))
运行:python3 BuildReleaseWithLegu.py build_release
完整源码:https://github.com/qhyuan/toolkit/blob/master/scripts/BuildReleaseWithLegu.py