Adding Google Guava to Android project - significantly slows down the build

筅森魡賤 提交于 2019-12-18 18:53:08

问题


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

  1. Can it be the cause for the build slowdown?
  2. Are there anything can be done to speed this up?

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

Thanks

Alex


回答1:


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.

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.

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.



来源:https://stackoverflow.com/questions/7548038/adding-google-guava-to-android-project-significantly-slows-down-the-build

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!