如果我有一个链接了许多图书馆项目的项目,我可以通过将每个项目包装在AAR中并将其包含在主项目中来提高构建性能吗?或者这没有任何区别,因为当编译器需要组装apk时,它还需要将所有内容打包在一起吗?
感谢任何一位能给我一些关于2方法之间性能差异的澄清的人
答案 0 :(得分:1)
I don't think you will save any build time by wrapping an existing .jar file into a .aar file and using that instead of the original .jar file.
As this SO post notes, .aar files are basically just zip files which may contain a jar file and some android resources.
Also, because .aar files are not precompiled into Dalvik byte code, the build process for your apk file must still carry out that step at least once. So, you won't save dexing time just by wrapping the .jar file into a .aar file either.
If you build a typical Android Studio project (with some Android library dependencies specified in the gradle build file) you can see the directory underneath app/build/intermediates/exploded-aar where these files have been unzipped. That work must still be done by your build machine even though you are using a .aar file.
Finally, as you pointed out, the .apk packaging work must still be done at the end of the build.
答案 1 :(得分:1)
我认为(正在使用的)图书馆项目是最好的选择,原因有二: