1
votes

I have this project structure:

  • app
  • library1
  • dynamicFeature1
  • dynamicFeature2

Now, I want dynamicFeature2 to only be included in my development builds, and never appear in anything that could be released.

I used productFlavors like this:

    productFlavors {
        public {
            dynamicFeatures = [':dynamicFeature1']
        }
        development {
            dynamicFeatures = [':dynamicFeature1', ':dynamicFeature2']
        }
    }

This way I have both features in public* and development* variants, however if I comment out the dynamicFeatures line for development flavor, I will only have dynamicFeature1 in both flavors. So it kinda works, but not the way I want.

So, is there a way for app flavors to have different sets of dynamic features?

1

1 Answers

0
votes

I followed this question to solve it for now. I created a development source set for dynamicFeature2, where there is only a manifest file present. This manifest declares:

    <dist:module
        dist:instant="false"
        dist:title="@string/title_dynamic_feature_2"
        tools:node="replace">
        <dist:delivery>
            <dist:install-time />
        </dist:delivery>
        <dist:fusing dist:include="true" />
    </dist:module>

The manifest in main source set uses <dist:on-demand />. This way I only have dynamicFeature2 installed for development* variants, and I don't make a SplitInstallRequest for this feature.

This is only a workaround, as the bundle still contains dynamicFeature2 apk, which I hoped to not be built using gradle configuration.