Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

aar vs "plain module" advantages

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

like image 996
Apperside Avatar asked Jul 11 '16 18:07

Apperside


2 Answers

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.

like image 59
albert c braun Avatar answered Oct 19 '22 22:10

albert c braun


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.
like image 38
abhay anand Avatar answered Oct 19 '22 22:10

abhay anand