有没有一种简单的方法"关闭日志"之前释放市场上的应用程序? [英] Is there an easy way to "deactivate logging" prior to releasing your app on the market?

查看:121
本文介绍了有没有一种简单的方法"关闭日志"之前释放市场上的应用程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是preparing发布在市场上的应用程序,阅读的谷歌文档的位于此处它提出以下建议:停用任何呼叫日志中的源$ C ​​$ C方法

有一个不必经过我的所有的源文件,并手动删除每一行更简单的方法?

另外,为什么删除记录,它是一个资源猪?

解决方案

您可以通过的 ProGuard的。在最新的SDK和工具ProGuard的配置文件应该已经存在。克里斯托弗在类似的问题回答了这个。

  

最简单的方法可能是在部署之前通过ProGuard的运行编译的JAR,有一个配置,如:

  -assumenosideeffects类android.util.Log {
  公共静态INT V(...);
}
 

  

将 - 除了其他所有的ProGuard的优化 - 直接从字节code删除任何详细的日志报表

您可以决定要禁用哪些logoutputs通过添加

  -assumenosideeffects类android.util.Log {
  公共静态INT D(...);
  公共静态INT I(...);
  公共静态INT E(...);
}
 

要ProGuard的配置文件中。我喜欢保持.E消息在我的code,因为那些只在部分捕获部分使用所需的应用程序的正常执行过程中降低性能比较。

I'm preparing to release an app on the market place, on reading the Google documentation located here it suggests the following : Deactivate any calls to Log methods in the source code.

Is there an easier way than having to go through all my source files and remove each line manually?

Also, why remove the logging, is it a resource hog?

解决方案

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.

这篇关于有没有一种简单的方法"关闭日志"之前释放市场上的应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆