Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Library Module vs Feature Module

The latest update of Android Studio 3.0 allows creation of several module types. One of the new types is 'Feature Module' but I can't find details about it

What is the difference between the existing Android Library Module and the Feature Module and why should I use the latter?

The only difference I can see is that a Feature module defines an Application in the manifest. Can/should these Features be used as standalone apps? In what way do they differ from the actual Application module in that case?

like image 634
Nick Cardoso Avatar asked May 23 '17 16:05

Nick Cardoso


People also ask

What are feature modules in Android?

Feature modules are used in Instant apps and Android App Bundles so that when app requests a feature while using the instant app or App Bundles, the Play store loads only requested feature module code, and not others. In the case of Instant apps, once the user is done using the feature the code is discarded.

What is the difference between base and feature modules?

Each feature module will need to have a reference to your base module (in this diagram, the app module) — the feature module in this case will only contain the required code for the implementation of that feature, any code that is required from the core of your app will be obtained from the base module reference.

Are You working on a single module Android app?

We’ve all been there. Single module android applications — at some point in our Android development career it’s likely we’ve worked on, or are working on, a project that consists of a single module. Now, there’s nothing wrong with that at all and in a lot of cases, a single module will most likely do the job.

What is the difference between core modules and library plugins?

Core modules that contain android framework references will need to use the library plugin: Whilst on the other hand, core modules that do not reference the android framework can simply be pure kotlin / java modules:


2 Answers

Feature modules are used in Instant apps and Android App Bundles so that when app requests a feature while using the instant app or App Bundles, the Play store loads only requested feature module code, and not others. In the case of Instant apps, once the user is done using the feature the code is discarded. If you are working on a regular app and not instant app, I think you should be using Android library module.

Android App Bundles will be used to break up your app into small chunks so that a user doesn't have to download all of the code in your APK if they don't need it.

like image 89
mansi rao Avatar answered Nov 10 '22 13:11

mansi rao


Maybe a litte updated version...

Android Library is for instance a feature that u will need in your app but maybe using in other Apps as well. This is basically a constant part of your application.

The Dynamic Feature Module (or Instant Dynamic Feature Module for Instant Apps) can be used for temporary or feature based applications. Let's say you have an Onboarding Process that requires a 80MB library scan module. So, when the user enters the onboarding the module will be requested and installed. Once the user finished your onboarding process the scan module isn't needed anymore, so you can remove the module again from your app.

An other example: You created an app with subscription based features. As the user payed for your subscription.. 3 of 8 modules (features) are now accessible for the user and the feature/module is being installed on the users device.

So in conclusion, it might be wise or even necessary (max. APK sized reached) to use dynamic features to reduce your apps size.

Also see:

  • https://developer.android.com/guide/playcore/dynamic-delivery
  • https://developer.android.com/topic/performance/reduce-apk-size
like image 44
Javatar Avatar answered Nov 10 '22 12:11

Javatar