加入谷歌番石榴到Android项目 - 显著减慢构建番石榴、显著、项目、Android

2023-09-05 11:02:01 作者:尛腼腆

在加入谷歌番石榴R09到​​我们的Andr​​oid项目的建造时间显著的增加,特别是DEX生成阶段。据我所知,DEX代通吃我们班+我们靠大家罐子并将其转换成DEX格式。番石榴约1.1MB一个pretty的大罐子

After adding Google Guava r09 to our Android project the build time increased significantly, especially the DEX generation phase. I understand that DEX generation takes all our classes + all jars we depend on and translates them to DEX format. Guava is a pretty big jar around 1.1MB

也可以是事业,为构建放缓? 有没有什么可以做,以加快这?

P.S。通常我构建的IntelliJ,但我也试过用Maven构建 - 同样的结果

P.S. Usually I build from Intellij, but I also tried building with Maven - same results.

感谢

亚历

推荐答案

有关它的价值,我的直觉是,这不是原因。很难需要很长的时间做以字节code区区1.1MB任何东西;我从来没有注意到DEX采取任何显著的时间。但是让我们假设它是问题的只是就事论事。

For what it's worth, my gut is that this isn't the cause. It's hard to take a long time doing anything with a mere 1.1MB of bytecode; I've never noticed dex taking any significant time. But let's assume it is the issue for sake of argument.

如果它很重要的话,你也许可以切片番石榴的.jar 删除全包,你不要使用。它是由数块不一定是所有相互关联的

If it matters enough, you could probably slice up the Guava .jar to remove whole packages you don't use. It is composed of several pieces that aren't necessarily all inter-related.

我不认为这会加快速度,但也许值得一提的是:如果你运行构建通过Proguard的(现在捆绑了SDK优化器),它可以删除未使用的类之前,你要DEX(和,做了字节code一堆其他伟大的优化)。但是,当然,这可能是处理中需要更长的时间本身就比DEX-ING。

I don't think this is going to speed things up, but maybe worth mentioning: if you run the build through Proguard (the optimizer now bundled with the SDK), it can remove unused classes before you get to DEX (and, do a bunch of other great optimization on the byte code). But of course that process probably takes longer itself than dex-ing.