Should every module in Android Studio create a .so file?

Issue

I am new to Android Studio and trying to understand how it works. I have a project which is a mixed code base (C++ and Java) and trying to convert that to an Android Studio project.

As of now, I am building my app from command line because my app is currently not using any IDE, it is made up of multiple folders. I was wondering if I should be structuring my project such that every module creates a .so file? In another words should I have:

  1. One module and multiple folder under it
  2. Multiple modules

Does every module create one .so file or multiple .so files?

Solution

This depends on the size and complexity of your project. One advantage of having multiple shared libraries (.so files) is that if you make binary-compatible changes in one area of the codebase, you don’t have to recompile your entire project. You can just rebuild the module which you made changes in, and the dependent modules will link to the updated library.

If your project is quite large and rebuilding everything takes a long time, this can be a big timesaver. If you want to be able to reuse certain modules in other projects without having to pull in all the code from this project, it would make sense to separate into modules.

Splitting your C++ code into multiple modules does add some complexity to the build (and the syntax to specify C++ builds keeps changing on top of that), so you’ll want to take that into account when you decide.

Answered By – Francesca Nannizzi

Leave a Comment