有什么方法可以在不使用 ProGuard 优化的情况下删除日志记录调用吗?

发布于 2024-11-25 23:08:07 字数 470 浏览 2 评论 0原文

我有一个包装类,用于在开发过程中进行日志调用。这使得在任何给定时间打开或关闭所有日志记录变得容易(加上一些其他漂亮的功能)。以前,我使用特定的 ProGuard 优化在发布期间删除了此类,这也删除了对该类的静态方法的调用(因此没有留下任何日志字符串)。

不幸的是,因为这个,我必须禁用ProGuard的优化功能。虽然我可以轻松关闭日志记录,但我的所有日​​志字符串在生成的 apk 中仍然可见,除非我遗漏了某些内容,否则 ProGuard 中没有其他方法可以删除它们。

在 Eclipse GUI 中构建发行包时是否有其他方法可以删除这些字符串? (不是蚂蚁金服)

I have a wrapper class for making log calls during development. This makes it easy to turn all logging on or off at any given time (plus some other nifty features). Previously I used a specific ProGuard optimization to remove this class during release, which also removed the calls to the class's static methods (so no log strings were left behind).

Unfortunately because of this, I have to disable ProGuard's optimization feature. While I can easily turn off the logging, all of my log strings are still visible in the resulting apk, and unless I'm missing something, there is no other way in ProGuard to remove them.

Is there any other way to remove these strings when building a release package in the Eclipse GUI? (not ANT)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

天暗了我发光 2024-12-02 23:08:07

我不知道你的字符串文字在哪里等,但要模拟 ifdef 调试语句,你会做一些事情 与此类似,如果您可以将调试类的所有受影响的内部类/方法/var 包装在这样的语句中,这可能是微不足道的。

显然,编译器删除了它在该块中找到的任何内容,或多或少是死代码,或者我已经读过,但从未检查过它。

I don't know where you string literals are etc. but to simulate a ifdef debug statement you would do something similar to this which may be trivial if you can just wrap all the affected inner class/method/var's of your debugging class in such a statement.

Apparently the compiler removes anything it finds in that block as more or less dead code, or so I have read, never checked it out though.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文