0

I'm trying out the Android's latest app packaging and delivery model, App Bundles.

I've created a dynamic feature module and defined a dependency on the main app.

implementation(':app')

Now my app module has different productFlavors.

productFlavors {
  free {
    ...
  }

  pro {
    ...
  }
}

My dynamic feature does not require any product flavors. But I now get the following error on gradle sync -

Unable to resolve dependency for ':dynamic_feature@debug/compileClasspath': 
Could not resolve project :app.

I can fix this by defining the same productFlavors in my dynamic feature module, but is it absolutely necessary?

I am generalizing a case where I have many different submodules and productFlavors and defining productFlavors in each module feels redundant.

Sudarshan Bhat
  • 3,772
  • 2
  • 26
  • 53
  • Have you checked this related [SO post](https://stackoverflow.com/questions/46949622/android-studio-3-0-unable-to-resolve-dependency-for-appdexoptions-compileclas)? – Jessica Rodriguez Nov 27 '18 at 07:47

1 Answers1

0

In this case you'll have to declare a missingDimensionStrategy for the dynamic feature module which doesn't have the flavor.

In your com.android.dynamic-feature module you'd add something like this

android {
// other things
    defaultConfig {
        // other things
        missingDimensionStrategy 'pro' // or whichever dimension you want to use
    }
}

You can find more about this and why this is necessary in the documentation.

Ben Weiss
  • 17,182
  • 6
  • 67
  • 87