的zipalign验证 [英] ZipAlign verification

查看:156
本文介绍了的zipalign验证的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Android中,的zipalign 是用来对准在4个字节边界资源,以加快资源加载:

In Android, ZipAlign is used to align resources on 4 bytes boundaries to speed-up resources loading:

资源装卸code在Android中可以有效地访问资源
  当他们通过在4字节边界对齐内存映射他们。但
  对于未对准的资源(即当的zipalign尚未运行
  在一个APK),它有回落到明确阅读他们,这是
  慢,消耗更多的内存。

The resource-handling code in Android can efficiently access resources when they're aligned on 4-byte boundaries by memory-mapping them. But for resources that are not aligned (i.e. when zipalign hasn't been run on an apk), it has to fall back to explicitly reading them—which is slower and consumes additional memory.

运行该工具后,可以使用命令来验证对准

After running the tool, it is possible to validate the alignment using the command.

zipalign -c -v 4 application.apk

这生成一个报告,如果有错误或不告诉。在我而言,这个报告表示没有对准误差,但第一个数字,我认为它在最后APK资源的位置,似乎表明某些资源没有在4字节边界对齐。

This produces a report and tells if there are errors or not. In my case, this reports indicates no alignment error, but the first number, which I assume it the position of the resources in the final APK, seems to show that some resources are not aligned on 4 bytes boundaries.

下面是这份报告的开头:

Here is a the beginning of this report:

    Verifying alignment of APP-signed-aligned.apk (4)...
      50 META-INF/MANIFEST.MF (OK - compressed)
   24245 META-INF/KEYS.SF (OK - compressed)
   49830 META-INF/KEYS.DSA (OK - compressed)
   50683 AndroidManifest.xml (OK - compressed)
   53096 assets/Assets/DB_Normal.db (OK)
  595425 assets/Assets/Common/DM/Structures.xml (OK - compressed)

我错过了什么?是第一个数字资源的位置?例如 Structures.xml 似乎是 595425 ,这是不是4字节的倍数。

What did I miss? Is the first number the position of the resource? For example Structures.xml seems to be at 595425, which is not a multiple of 4 bytes.

推荐答案

对齐不要紧,COM pressed数据。

The alignment doesn't matter for compressed data.

的想法是能够存储器映射uncom pressed块,并直接访问它们。比如说,如果你的PNG德codeR试图访问数据为32位整数,你有模拟最坏情况ARM CPU的行为,当你做一个不对齐的32位访问抛出SIGBUS一个仿真器,那么你不能平凡访问的图象数据,如果它是不对齐的。

The idea is to be able to memory-map the uncompressed chunks and access them directly. If, say, your PNG decoder tries to access data as 32-bit integers, and you have an emulator that emulates worst-case ARM CPU behavior and throws a SIGBUS when you do an unaligned 32-bit access, then you can't trivially access the image data if it isn't aligned.

zlib的膨胀code不关心,所以的zipalign不打扰对准COM pressed数据。

The zlib inflate code doesn't care if the data is aligned, so zipalign doesn't bother aligning the compressed data.

这篇关于的zipalign验证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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