Is there an easy way to “deactivate logging” prior to releasing your app on the market?

笑着哭i 提交于 2019-12-03 07:29:26
Janusz

You can do this through proguard. In the latest SDK and tools a proguard configuration file should already exist. Christopher answered this in a similar question.

The easiest way is probably to run your compiled JAR through ProGuard before deployment, with a config like:

-assumenosideeffects class android.util.Log {
  public static int v(...);
}

That will — aside from all the other ProGuard optimisations — remove any verbose log statements directly from the bytecode.

You can decide which logoutputs you want to disable through adding

-assumenosideeffects class android.util.Log {
  public static int d(...);
  public static int i(...);
  public static int e(...);
}

to the proguard config file as well. I like to keep the .e Messages in my code because those are only used in some catch parts want decrease perfomance during the normal execution of the application.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!