In Android Studio 3 there are at least two new module types. First is Instant app module
and the second one is feature module
. With Instant App module
it's quite obvious but feature module
from my perspective is the same as the library module
. So what is the real difference between library
and feature
modules and when I should use library module
and when feature module
?

- 4,721
- 3
- 31
- 44
5 Answers
I would complete Marcin Orlowski scheme like this. You could picture library module in the same way as dependencies of a given feature or base module.
Hence the library modules will not be packaged in Instant APP APK.

- 4,449
- 2
- 20
- 30
-
2And Lib D should be also available to Feature 1 and Feature 2 both. – Zon Mar 19 '18 at 05:39
A feature module is a module that applies com.android.feature plugin.
This module type has a dual nature:
When consumed by an application (com.android.application) during build, it produces an aar and works just like a library
When consumed by an Instant App APK (com.android.instantapp), it generates an Instant App APK Developers should write feature modules just like library modules. The tools provided are responsible for applying the correct nature when used during a build.
In the simplest case an Instant app can have a single feature module. If there is more than one feature module, these feature-to-feature dependencies can be defined through the api configuration. In any case, there must only be a single base feature which is marked with a baseFeature attribute.
Main source: https://codelabs.developers.google.com/codelabs/android-instant-apps/#3

- 24,642
- 24
- 96
- 146
This all for Instant Apps so you only need it if you are making your app supporting instant app feature
See https://developer.android.com/topic/instant-apps/getting-started/structure.html#basic-app

- 72,056
- 11
- 123
- 141
Android SDK is the core features and software tools that allow you to create an app for the Android Platform. An SDK contains lots of libraries and tools which you will use to develop your application.
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.
The 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 And Jar.

- 1,550
- 2
- 13
- 29
-
The question is about differences between library module and feature module in Android Studio, and not about library nad module difference – Stepango Jun 30 '17 at 03:44
Use Feature for linked feature of your instant app (to launch it with deeplink).
Use Library for code dependency in your app or in your Feature modules.

- 51
- 3