I have some big chunks of code which test the behaviour of some incompletely documented Android APis (sigh) which seem to behave differently for different Android versions and I want to switch them in and out of debug builds (they are always removed from release builds) which I try to do using buildConfigFields in build.gradle like this
buildTypes {
release {
minifyEnabled true
buildConfigField("boolean", "RINGERMODETEST", "false")
...
}
debug {
// set this to false to remove the optional code
buildConfigField("boolean", "RINGERMODETEST", "true")
...
}
}
Then in my code I have
if (BuildConfig.RINGERMODETEST) {
// optional code
}
To get the optional code removed I need to turn on the optimiser, but setting minifyEnabled would turn on obfuscation as well which I don't want in a debug build. There is an earlier answer to this question for Proguard at Proguard shrinking and optimizing without obfuscation, but there doesn't seem to be any documentation which says how to do it for R8. I really don't want to have to learn how to construct a complete proguard control file when it's supposed to be superseded by R8. and useProguard will apparently soon be deprecated.