How to remove all debug logging calls before building the release version of an Android app?

前端 未结 27 1532
有刺的猬
有刺的猬 2020-11-22 07:39

According to Google, I must \"deactivate any calls to Log methods in the source code\" before publishing my Android app to Google Play. Extract from section 3 of th

27条回答
  •  悲哀的现实
    2020-11-22 08:28

    I have a very simple solution. I use IntelliJ for development, so the details vary but the idea should apply across all IDE's.

    I pick to root of my source tree, right-click and select to do "replace". I then choose to replace all "Log." with "//Log.". This removes all log statements. To put them back later I repeat the same replace but this time as replace all "//Log." with "Log.".

    Works just great for me. Just remember to set the replace as case sensitive to avoid accidents such as "Dialog.". For added assurance you can also do the first step with " Log." as the string to search.

    Brilliant.

提交回复
热议问题