【问题标题】:How can I tell which classes Proguard warns me about?我如何知道 Proguard 会警告我哪些类?
【发布时间】:2016-07-23 00:52:44
【问题描述】:

我正在尝试发布我的应用程序,而 ProGuard 导致我的服务器代码出现各种错误,所以我进入 gradle 控制台并看到了这个:

Note: there were 2 references to unknown classes.
  You should check your configuration for typos.
  (http://proguard.sourceforge.net/manual/troubleshooting.html#unknownclass)
Note: there were 26 unkept descriptor classes in kept class members.
  You should consider explicitly keeping the mentioned classes
  (using '-keep').
  (http://proguard.sourceforge.net/manual/troubleshooting.html#descriptorclass)
Note: there were 22 unresolved dynamic references to classes or interfaces.
  You should check if you need to specify additional program jars.
  (http://proguard.sourceforge.net/manual/troubleshooting.html#dynamicalclass)
Note: there were 15 accesses to class members by means of introspection.
  You should consider explicitly keeping the mentioned class members
  (using '-keep' or '-keepclassmembers').
  (http://proguard.sourceforge.net/manual/troubleshooting.html#dynamicalclassmember)

这一切都很好,但我怎么知道 ProGuard 正在谈论哪些具体参考?他们肯定不希望我独立找到/记住这些参考资料吗?

【问题讨论】:

    标签: android proguard


    【解决方案1】:

    在您的模块特定构建文件夹中,创建了usage.txt 文件。

    build/outputs/mapping/release/usage.txt
    

    此文件包含删除的所有方法以及受影响的类。确保不会删除您自己项目中的任何重要类。

    【讨论】:

    • 你的proguard规则会阻止应用代码被混淆吗?
    • 是的,它使我的代码保持原样。可能不是最佳做法。但是您仍然可以检查usage.txt并查看proguard删除了您的哪些代码。
    • 我正在浏览它,发现它只是一个巨大的方法和类列表。有什么方法可以让我看到 ProGuard 注意到了什么?很奇怪,它命名了 26 个未保留的描述符类,却没有列出它们是什么......?
    • 没关系,我是 div。它在我发布的摘录上方的 gradle 控制台中列出了注意的引用/类。叹息
    • 好的!但请确保包含每个库所需的所有 proguard 规则,并将它们保存在 proguardrules.pro 中,并验证 usage.txt。某些文件可能会被删除并且可能会被忽视
    【解决方案2】:

    您需要将详细开关添加到 ProGuard 配置文件中:

    -verbose
    

    ProGuard Manual 解释了这些注意事项 - 以及如何修复它们。

    【讨论】:

    • 链接已损坏
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-10-26
    • 2020-10-04
    • 2017-05-14
    • 2011-09-17
    • 2021-01-18
    • 2020-02-27
    相关资源
    最近更新 更多