Make sure you are referencing your project’s BuildConfig class, not from any of your dependency libraries.
if (BuildConfig.DEBUG) { // do something for a debug build }
release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' debuggable false } debug { debuggable true }
References
https://stackoverflow.com/questions/23844667/detect-if-i-am-in-release-or-debug-mode-in-android
http://tekeye.uk/android/examples/android-debug-vs-release-build