I have some code in my android application which I intend to keep only in debug-builds.
I am aware of this approach:
if (BuildConfig.DEBUG) {
//code here
}
However, the problem is that my code relies on external dependencies which I would also like to keep in debug builds only :
debugCompile "dependency1"
//this wont compile in release mode
if (BuildConfig.DEBUG) {
//code which references dependency1
}
Given that there is no conditional compilation in java, are there any solutions besides commenting out blocks of code manually every time (which is obviously a huge hassle)?
EDIT: Egor pointed me in the right direction and after doing some more reasearch on "source sets" I found an answer which PRECISELY describes my situation and provides an excellent solution: https://stackoverflow.com/a/31483962/5790273