I created a new Android project and found out that I cannot use the next piece of code:
if (BuildConfig.DEBUG) {
//code
}
I tried to find another way to get Debug mode flag on the internet, but I didn't find a new solution, only a very old one. What is the alternative to the BuildConfig.DEBUG flag?
The reason for the issue is the last version of Gradle: 8.0.
Thanks to @cmak I found out the next solution: the in build.gradle file of an app, add the buildFeatures { buildConfig = true } flag.
If 'android.defaults.buildfeatures.buildconfig = true' is not enough, then perhaps the menu will help: Build -> Rebuild Project.
A 'java (genereted)' folder containing the 'BuildConfig' class should then be created in the project navigator.
Build -> Rebuild must be called separately for each build (release, debug, ...) so that the class is created.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With