为什么需要未对齐的 apk? [英] why unaligned apk is needed?

查看:37
本文介绍了为什么需要未对齐的 apk?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Android gradle 以两个二进制文件生成 apk:未对齐和对齐.

Android gradle produces apk in two binaries: unaligned and aligned.

文档说...

使用私钥对 APK 进行签名后,对文件运行 zipalign.此工具可确保所有未压缩的数据以特定的字节对齐开始,相对于文件的开头.安装在设备上时,确保在 4 字节边界对齐可提供性能优化.对齐后,Android 系统能够使用 mmap() 读取文件,即使它们包含具有对齐限制的二进制数据,而不是从包中复制所有数据.好处是减少了正在运行的应用程序消耗的 RAM 量.

Once you have signed the APK with your private key, run zipalign on the file. This tool ensures that all uncompressed data starts with a particular byte alignment, relative to the start of the file. Ensuring alignment at 4-byte boundaries provides a performance optimization when installed on a device. When aligned, the Android system is able to read files with mmap(), even if they contain binary data with alignment restrictions, rather than copying all of the data from the package. The benefit is a reduction in the amount of RAM consumed by the running application.

似乎强烈建议分发对齐的apk.对我来说,我只使用 aligned apk 作为结果产品而忽略 unaligned apk.

Seems like aligned apk is strongly recommended to distribute. For me, I only use aligned apk as a result product and ignore unaligned apk.

未对齐的apk在开发过程中有什么特殊用途吗?

Does unaligned apk have any special usage during development?

推荐答案

这是一个两步过程.未对齐的apk只是一个中间产物.

It is a two step process. The unaligned apk is just an intermediate product.

  1. 生成未对齐的apk
  2. 未对齐的对齐并生成对齐的 apk

这篇关于为什么需要未对齐的 apk?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆