The following combination of snippets allows you to use different debug and release functionality in a library module depending on the debug/release build type of the parent app module.
Library module
android {
defaultConfig {
defaultPublishConfig 'release'
publishNonDefault true
}
}
App module
dependencies {
debugImplementation project(path: ':lib', configuration: 'debug')
releaseImplementation project(path: ':lib', configuration: 'release')
}