Unable to build feature modules in a multi-flavor app

Thanks to user TWL who pointed me towards google samples for instant apps, with an example for flavors.

We need flavor declarations in all the feature modules, application module and instant-app module as well. Library modules can be skipped as of today with plugin version 3.1.1. In other words, have this section in all feature and installed/instant modules:

flavorDimensions "dim"
productFlavors{
    a{
        dimension "dim"
    }
    b{
        dimension "dim"
    }
}