gpt4 book ai didi

android - 在市场上发布您的应用程序之前,是否有一种简单的方法来获取 "deactivate logging"?

转载 作者:塔克拉玛干 更新时间:2023-11-02 19:53:01 27 4
gpt4 key购买 nike

我正准备在市场上发布一个应用程序,阅读谷歌文档 located here它建议如下:停用源代码中对 Log 方法的任何调用。

有没有比必须遍历所有源文件并手动删除每一行更简单的方法?

此外,为什么要删除日志记录,它是否占用资源?

最佳答案

您可以通过 proguard 完成此操作.在最新的 SDK 和工具中,proguard 配置文件应该已经存在。 Christopher 在 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.

您可以通过添加来决定要禁用哪些日志输出

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

混淆配置文件。我喜欢将 .e 消息保留在我的代码中,因为它们仅用于某些捕获部分,希望在应用程序的正常执行期间降低性能。

关于android - 在市场上发布您的应用程序之前,是否有一种简单的方法来获取 "deactivate logging"?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5141751/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com