app-debug.apk 和 app-debug-unaligned.apk 之间的区别
Difference between app-debug.apk and app-debug-unaligned.apk
在构建变体设置为 "debug" 模式的 android 工作室中,我发现了 apk
的两个输出
- 应用-debug.apk
- 应用调试-unaligned.apk
这些文件有什么区别?
未对齐的apk只是一个中间apk。首先,生成未对齐的apk。然后,未对齐的 apk 对齐并生成对齐的 apk,即 app-debug.apk。您可以通过 here.
阅读更多相关信息
简答:
app-debug-unaligned.apk
= 未对齐签名 APK
app-debug.apk
= 对齐签名 APK(使用 zipalign 优化的 RAM)
长答案
要了解差异,我们需要了解以下几点:
应用签名过程
- 生成私钥(keytool)
- 编译得到未签名的 APK -> 未对齐的未签名 APK
- 使用私钥 debug/release 模式签署应用程序 (jarsigner) -> 未对齐签名的 APK
- 对齐 APK (zipalign) -> 对齐签名 APK
整个签名过程得到解释here。
为什么我们需要中间 app-debug-unaligned.apk
?
根据 docs:
Caution: zipalign must only be performed after the .apk file has been
signed with your private key. If you perform zipalign before signing,
then the signing procedure will undo the alignment.
有什么好处? zipalign?
优点是对齐的 APK 针对 RAM 使用进行了优化,因此它们在设备中消耗的 RAM 更少。来自 docs:
zipalign is an archive alignment tool that provides important
optimization to Android application (.apk) files. ....The benefit is a
reduction in the amount of RAM consumed when running the application.
在构建变体设置为 "debug" 模式的 android 工作室中,我发现了 apk
的两个输出- 应用-debug.apk
- 应用调试-unaligned.apk
这些文件有什么区别?
未对齐的apk只是一个中间apk。首先,生成未对齐的apk。然后,未对齐的 apk 对齐并生成对齐的 apk,即 app-debug.apk。您可以通过 here.
阅读更多相关信息简答:
app-debug-unaligned.apk
= 未对齐签名 APK
app-debug.apk
= 对齐签名 APK(使用 zipalign 优化的 RAM)
长答案
要了解差异,我们需要了解以下几点:
应用签名过程
- 生成私钥(keytool)
- 编译得到未签名的 APK -> 未对齐的未签名 APK
- 使用私钥 debug/release 模式签署应用程序 (jarsigner) -> 未对齐签名的 APK
- 对齐 APK (zipalign) -> 对齐签名 APK
整个签名过程得到解释here。
为什么我们需要中间 app-debug-unaligned.apk
?
根据 docs:
Caution: zipalign must only be performed after the .apk file has been signed with your private key. If you perform zipalign before signing, then the signing procedure will undo the alignment.
有什么好处? zipalign?
优点是对齐的 APK 针对 RAM 使用进行了优化,因此它们在设备中消耗的 RAM 更少。来自 docs:
zipalign is an archive alignment tool that provides important optimization to Android application (.apk) files. ....The benefit is a reduction in the amount of RAM consumed when running the application.