dilix
dilix

Reputation: 3893

No classes from main sources from multi flavor library

I have a library project with 2 flavors

configurations {
    // Initializes placeholder configurations that the Android plugin can use when targeting
    // the corresponding variant of the app.
    internalDebug {}
    internalRelease {}
    externalDebug {}
    externalRelease {}
}

flavorDimensions("outerInner")
productFlavors {
    internal{dimension "outerInner"}
    external{dimension "outerInner"}
}

No custom sourceSets defined in build.gradle

For one of the flavor I have custom layouts inside:

enter image description here

All other sources should be from main.

When I include this libaryr to app:

implementation project(path: ':sdk', configuration: 'internalDebug')

There no classes of the sdk library at all and all imports marks as red.

The question is why there is no sources from main's library folders in app?

Upvotes: 1

Views: 130

Answers (1)

dilix
dilix

Reputation: 3893

Finally I got the solution as defining missingDimensionStrategy in app's build.gradle.

// Specifies a sorted list of flavors that the plugin should try to use from
// a given dimension. The following tells the plugin that, when encountering
// a dependency that includes a "minApi" dimension, it should select the
// "minApi18" flavor. You can include additional flavor names to provide a
// sorted list of fallbacks for the dimension.
missingDimensionStrategy 'outerInner', 'internal'

It means that if during the build gradle will found a dependency that have the flavorDimension outerInner it should use internal for that.

After this is applied I could simply include

implementation project(path: ':sdk')

For each app's buildType it will use appropriate debug or relese SDK build and fallback to internal implementation.

External implementation is delivered to maven with artifact bundleExternalDebugAar setting.

Upvotes: 1

Related Questions