What is the best way to remove logging from production android application. It appears that proguard does not do this completely, strings still get written, so I was wondering what is best solution to remove the logging from production code?
What is the best way to remove logging from production android application. It appears
Share
The IMO best solution is to write code like below wherever you call your logging methods.
By changing 1 constant you strip away every logging that you don’t want. That way the part behind
if (false)should not even get into your .class file since the compiler can completely remove it (it is unreachable code).This also means that you can exclude whole code blocks from your release software if you wrap them in that
if. That’s something even proguard can’t do.the
SOME_LOG_CONSTANTcan beBuildConfig.DEBUGif you use SDK Tools r17 and above. That constant is automatically changed for you depending on build type. Thx @Christopher