As far as I know, in android \"release build\" is signed APK. How to check it from code or does Eclipse has some kinda of secret defines?
I need thi
First add this to your build.gradle file, this will also allow side by side running of debug and release builds:
buildTypes {
debug {
applicationIdSuffix ".debug"
}
}
Add this method:
public static boolean isDebug(Context context) {
String pName = context.getPackageName();
if (pName != null && pName.endsWith(".debug")) {
return true;
} else {
return false;
}
}
Another option, worth mentioning. If you need to execute some code only when debugger is attached, use this code:
if (Debug.isDebuggerConnected() || Debug.waitingForDebugger()) {
//code to be executed
}
Solved with android:debuggable
. It was bug in reading item where in some cases debug flag on item was not being stored in record getting if (m.debug && !App.isDebuggable(getContext()))
always evaluated to false
. My bad.
Answered by Mark Murphy
The simplest, and best long-term solution, is to use BuildConfig.DEBUG
. This is a boolean
value that will be true
for a debug build, false
otherwise:
if (BuildConfig.DEBUG) {
// do something for a debug build
}