Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

App module vs Library Module

I am confused about the difference between Library Module and App module. I did google it but I didn't quite find a clear difference. The Android studio docs goes about how you can convert app module into library module.

What is really the difference? When do you use what? It seems to me that both are essentially the same.

Thanks

like image 279
Snake Avatar asked Oct 19 '16 20:10

Snake


2 Answers

An app module builds an app. A library module builds a library.

An app is what a user uses. The output of an app module is an APK, the package of an Android application.

A library is a collection of code that represents something that you want to use in multiple applications or otherwise want to keep in a separate "container" than the rest of the app code. The output of a library module is an AAR.

So, for example, this Android Studio project contains a netsecurity/ library module, representing some code that can be used by zero, one, or many app modules. Specifically, the library helps with advanced SSL configurations (self-signed certificates, certificate pinning, etc.). The project also contains a demo/ app module, which creates an Android app that uses the netsecurity/ library module and demonstrates its use.

like image 75
CommonsWare Avatar answered Sep 26 '22 00:09

CommonsWare


A Library is a collection of pre-built compiled code which you can use to extend your application's features. For example, you may need to show some graphics in your application. Instead of creating this from scratch, you may choose to use a pre-built library someone else has developed which will give you the features you need thus saving you some time.

A module is a small part of the application which can be tested and debugged on its own without needing the whole application. This is same for any programming language. Suppose you are building an app with Login feature. To test if the login feature works, you don't need the whole app. Thus the Login part is a module of your application.

like image 39
compte14031879 Avatar answered Sep 24 '22 00:09

compte14031879