Home » Android » How to Remove all debug logging calls before publishing app to Google Play? [closed]

How to Remove all debug logging calls before publishing app to Google Play? [closed]

Posted by: admin May 30, 2018 Leave a comment

Questions:

According to Google, I must “deactivate any calls to Log methods in the source code” before publishing my Android app. Extract from section 5 of the publication checklist:

Make sure you deactivate logging and disable the debugging option before you build your application for release. You can deactivate logging by removing calls to Log methods in your source files.

My open-source project is large and it is a pain to do it manually every time I release. Additionally, removing a Log line is potentially tricky, for instance:

if(condition)
  Log.d(LOG_TAG, "Something");
data.load();
data.show();

If I comment the Log line, then the condition applies to the next line, and chances are load() is not called. Are such situations rare enough that I can decide it should not exist?

This is on the official checklist, so I guess many people do this on a regular basis.
So, how to efficiently but safely remove all Log lines?

Answers: