Suppose I have an Android app with three build types:
buildTypes {
release {
....
}
optRelease {
....
}
debug {
....
You can use matchingFallback
buildTypes {
release {
matchingFallbacks = ['debug']
...
}
optRelease {
matchingFallbacks = ['release']
...
}
debug {
matchingFallbacks = ['debug']
...
}
}
You can also specify list of fallback as follows:
optRelease {
matchingFallbacks = ['release','debug']
}
This will specify a sorted list of fallback build types that the plugin should try to use when a dependency does not include a "optRelease" 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.
You can refer to official document for more details.
However if you want to use variant-specific configurations when targeting external dependencies. You can do it as follows:
debugImplementation project(':myDependency')
This will make myDependency
as a dependency to only the "debug" version of your module.