Android debug / release version of application

669 views Asked by At

I have one question about finding if your application is in release mode or in debug. I need to find a way to detect the applications mode automatically with a function. For now I'm using a simple way declaring a boolean which everytime I have to change true/false. But sometimes me, or the other developer may forget to change it. Actually I need this because, I'm using an error handler in my app which is sending to our server exceptions which are uncaught. And I don't want to do this in debug mode.

So is there any way I can detect this with some functions which my app will do automatically, without using any variables like I do?

2

There are 2 answers

0
cwin On

There is no general solution but you may use isDebuggerConnected.

BUT this solution would also trigger/show the debug features if your users connect their phones to the PC and uses ddms themselves.

Maybe you sould combine this with one of the checks Aleks G suggested, and popup a Toast-message on every start that reminds you to disable debug ;-)

0
m02ph3u5 On

Why not use this?

if (BuildConfig.DEBUG) {
    // what shall happen in debug version
} else {
    // release version
}