Support Flavors and BuildTypes across library modules

“Refactor your app, if necessary.” … Preparing your App for Instant App

As per advised in developer.android.com, one might need to refactor it’s App into several modules in order to meet the 4Mb limit of Instant App when one support it. Hence it’s good to start looking into partitioning our App into smaller module.

For a sizable App though, we normally have various build variants e.g. BuildType and ProductFlavor. How do we propagate our our build variants we selected across library modules that we created?

It wasn’t a problem when we use library from other, since we don’t expert them to follow our build configuration (e.g. we don’t expect them in debug mode, or in Production Flavor etc). They are expected to work in one configuration.

But now, when we partition our entire project into modules, we might need them to follow our own build configuration. Below are the steps to make that possible.

1. Setup Your Flavor for Each Modules

This is as what you have done when you have a single App module to work on. When you have partition your App into multiple modules, you need to do like wise for each of them in their individual build.gradle file.

--

--