I have two builds variant one is in debugging and other is release. I have to run some block of code in release mode. For example, I have to use Firebase only in the release build,Is there any way to do that?
It means you have to give sign build in debug version also in build gradle. So It will have the same sign as release build and you can debug when it runs.
You can now debug your release build application. To find a problem, step through the code (or use Just-In-Time debugging) until you find where the failure occurs, and then determine the incorrect parameters or code.
Press Ctrl + Alt + F5 (or Shift + F9 ) to launch the app in debug mode. Choose Run -> Attach to process and select the signature of an app to enable the debug mode, which is already installed via adb.
For Check the release mode use
if( BuildConfig.BUILD_TYPE.equalsIgnoreCase("release")) {
}
debug mode check
if( BuildConfig.BUILD_TYPE.equalsIgnoreCase("debug")) {
}
or you can use this code
if( BuildConfig.DEBUG ){
}
use BuildConfig.DEBUG
to check is in debug mode
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