It is possible to set a variable in debug
or release
of buildTypes
of app module. This doc has explained how to do that, Android: Managing different server URL for development and release.
However, my problem is different slightly. I have Project_A which is dependency to my App_Module. A class on my Project_A needs to know this build is Debug or Release. I created a variable in buildTypes
based on what above doc's said (in App_Module). However, the variable seems is not visible to this dependency (Project_A).
I have following code in a class of Project_A:
if (BuildConfig.DEBUG)
{
MyConstants.URL_BASE = "https://my.debug.com";
}
else
{
MyConstants.URL_BASE = "https://my.release.com";
}
When I check the package of BuildConfig
, the package belongs to Project_A (and there is no sign of App_Module in dropdown list of auto import packages). So what is your recommendation? How can I check build variant from dependency?