matchingFallbacks
Specifies a sorted list of build types that the plugin should try to use when a direct
variant match with a local module dependency is not possible.
Android plugin 3.0.0 and higher try to match each variant of your module with the same one
from its dependencies. For example, when you build a "freeDebug" version of your app, the
plugin tries to match it with "freeDebug" versions of the local library modules the app
depends on.
However, there may be situations in which your app includes build types that adependency does not. For example, consider if your app includes a "stage" build type, but
a dependency includes only a "debug" and "release" build type. When the plugin tries to build
the "stage" version of your app, it won't know which version of the dependency to use, and
you'll see an error message similar to the following:
Error:Failed to resolve: Could not resolve project :mylibrary.
Required by:
project :app
In this situation, you can use matchingFallbacks to specify alternative
matches for the app's "stage" build type, as shown below:
// In the app's build.gradle file.
android {
buildTypes {
release {
// Because the dependency already includes a "release" build type,
// you don't need to provide a list of fallbacks here.
}
stage {
// Specifies a sorted list of fallback build types that the
// plugin should try to use when a dependency does not include a
// "stage" build type. You may specify as many fallbacks as you
// like, and the plugin selects the first build type that's
// available in the dependency.
matchingFallbacks = ['debug', 'qa', 'release']
}
}
}
Note that there is no issue when a library dependency includes a build type that your app
does not. That's because the plugin simply never requests that build type from the
dependency.
|