有没有关于Android构建过程中优化的详细描述?

发布于 2024-08-27 00:40:31 字数 455 浏览 6 评论 0原文

我一直对 .apk 构建过程中的所有优化感到好奇。我很好奇,因为我过去尝试过两件事来减小 .apk 的大小:

  1. 我之前在项目中拥有一些大型 json 资产,以及静态 sqlite 数据库。我尝试在构建过程之前通过 gzip 压缩 apk 来减小 apk 的大小,但生成的大小完全相同。

  2. 我今天刚刚在我的 /drawable/ 文件夹上尝试了 pngcrush。生成的版本与之前的大小完全相同。

我认为也许 #1 可以通过 zip 过程来解释,但简单地压缩 #2 中的 /drawable/ 文件夹会导致不同大小的文件。也许构建过程运行类似于 pngcrush 的东西?

无论如何,我想知道是否有人知道在哪里可以找到 Android 构建过程中所有优化的详细描述。我不想浪费时间尝试优化已经自动化的内容,而且我认为这将有助于我理解生成的 apk。有谁知道这是否记录在任何地方?

I've been curious as to all the optimizations that go into the building of an .apk. I'm curious because of two things I've tried in the past to bring down the size of my .apk:

  1. I have had a few large json assets in projects before, as well as a static sqlite database. I tried bringing down the size of the apk by gzipping them before the build process, but the resulting size is exactly the same.

  2. I just today tried pngcrush on my /drawable/ folders. The resulting build was exactly the same size as before.

I would think that perhaps #1 could be explained by the zip process, but simply zipping the /drawable/ folders in #2 result in different-sized files. Perhaps the build process runs something akin to pngcrush?

Regardless, I was wondering if anyone knew where to find a detailed description of all the optimizations in the Android build process. I don't want to waste my time trying to optimize what is already automated, and also I think it'd help my understanding of the resulting apk. Does anyone know if this is documented anywhere?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

清浅ˋ旧时光 2024-09-03 00:40:31

这两个是轻微“记录”的优化。

http://developer.android.com/guide/developing/tools/aapt。 html
“...Zip 兼容的档案 (...apk)...”
虽然我不确定它是否使用“最大”压缩...

http://developer.android.com/guide/topics/resources/resources-i18n.html#CreatingResources
注:放置在此处的图像资源可能会通过 aapt 工具进行无损图像压缩自动优化。例如,不需要超过 256 色的真彩色 PNG 可以使用调色板转换为 8 位 PNG “

并从 aapt 命令行
“指定像素容差以强制图像灰度”

至于其他选项......嗯。

these two are lightly 'documented' optimizations.

http://developer.android.com/guide/developing/tools/aapt.html
"... Zip-compatible archives (... apk) ... "
although I'm not sure that it uses 'maxmimum' compression ...

http://developer.android.com/guide/topics/resources/resources-i18n.html#CreatingResources
"Note: Image resources placed in here may be automatically optimized with lossless image compression by the aapt tool. For example, a true-color PNG that does not require more than 256 colors may be converted to an 8-bit PNG with a color palette"

and from the aapt commandline
"specify a pixel tolerance to force images to grayscale"

as to other opts ... ummm.

Smile简单爱 2024-09-03 00:40:31

使用 PNG 图像时有帮助的一件事是使用索引 PNG(gimp 可以轻松转换它)。索引 PNG 文件的大小约为“正常”PNG 的三分之一。如果您有很多图像,那么它确实有助于减小包大小。

One thing that will help when you use PNG images is to use indexed PNG (gimp can convert it easily). Indexed PNG files are about one third the size of the "normal" PNGs. If you have lots of images then it really helps reduce the package size.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文