Snake
Snake

Reputation: 14648

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

Upvotes: 16

Views: 8711

Answers (3)

Ben Butterworth
Ben Butterworth

Reputation: 28532

It's in the Android library documentation now. Lots more information there.

An Android library is structurally the same as an Android app module. It can include everything needed to build an app, including source code, resource files, and an Android manifest. However, instead of compiling into an APK that runs on a device, an Android library compiles into an Android Archive (AAR) file that you can use as a dependency for an Android app module.

Upvotes: 0

CommonsWare
CommonsWare

Reputation: 1006674

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.

Upvotes: 17

compte14031879
compte14031879

Reputation: 1591

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.

Upvotes: 4

Related Questions