Dynamic Feature Module with Product Flavors and App Bundle

Recently Google came out with a new app serving model: “Dynamic Feature Module”. The Overall concept is way-out like one has only to download data which he is using. I took this as a challenge and tried to implement in one of the largest sustainable projects of my obligation similar to PayTM which was quite intricate with 11 modules and 500+ MB size...

( 11 modules and 500+MB size is really insane )

There are too many blogs respecting how to enforce the dynamic module, app bundle, flavors in android but, this article is helpful for those who are in search of dynamic feature module with product flavors as there is relatively less information regarding this over the internet.

Assume there are two modules for example “App module” and “dynamic module”.

build.gradle (App module)

Dynamic module build.gradle

build.gradle (Dynamic Feature module)

App Module AndroidManifest.xml

Dynamic Module AndroidManifest.xml

AndroidManifest.xml (Dynamic Feature module)

Dynamic Module Download Method

  1. Eliminate multidex from app module.
  2. Eliminate data binding v2 from gradle.properties.
  3. Make sure you have implemented jcenter(), google() in all projects repositories in project app module gradle file.
  4. You need to override a method in application class as below…
  • override fun attachBaseContext(base: Context) {super.attachBaseContext(base)SplitCompat.install(this)}

5. In case you found any error as below.

  • It is because of repeated named resources…. refactor it and it will work.

These are some central highlighted issues I have gone through and overcame. This is a quite handy and simple explanation for dynamic feature with product flavors…

yes QUITE HANDY..

App Bundle is a wide concept. You no longer have to build, sign, and manage multiple APKs to support different devices, and users get smaller, more optimized downloads.

If you have any kind of issues, problems regarding app bundle, dynamic feature modules, product flavors, please ask it in the comment section.

Also check out: Implementation of .aar in a large project.

If you are seeing this…please clap…it won’t take hard on your palm…Thank you so much. It’s time to say “Good-Bye”…

Good Bye 👋

Google Associate Android Developer | Flutter Developer | Earning Experience by Learning Lessons

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store