aar vs "plain module" advantages
Asked Answered
D

2

7

if I have a project with many library projects linked, could I improve build performances by packaging each of them in an AAR and including it in the main project ? Or this will not make any difference since that when the compiler need to assemble the apk it need to package everything together anyway?

Thanks to any one who will give me some clarifcation about performance differences between the 2 approach

Difference answered 11/7, 2016 at 18:25 Comment(0)
I
3

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.

Inbreeding answered 11/7, 2016 at 20:33 Comment(0)
A
2

I believe the Library projects (which you are using) is the best way to go because of two reasons:

  1. The library project gives the direct access to the code base of the libraries which can be compiled and packaged together with the main app code
  2. In case, multiple .aar files are referenced within the project, then during the apk creation the unpacking, merging of resources and Manifest file will increase the build time.
Airspace answered 16/8, 2018 at 10:23 Comment(1)
+1 for "during the apk creation the unpacking, merging of resources and Manifest file will increase the build time" Thanks @abhayIntensify

© 2022 - 2024 — McMap. All rights reserved.