Suppose I have an Android app with three build types:
buildTypes {
release {
....
}
optRelease {
....
}
debug {
....
If you want to add a dependency for a variant that combines a product flavor and a build type, then you must initialize the configuration name in the configurations block.(如果想为自定义的buildTypes来添加dependencies,需要配置configurations {})
android {
buildTypes {
release {
....
}
optRelease {
....
}
debug {
....
}
}
}
configurations {
// Initializes a placeholder for the optReleaseImplementation dependency configuration
optReleaseImplementation {}
}
dependencies {
debugImplementation xxx
// Then it can work
optReleaseImplementation xxx
releaseImplementation xxx
}