如何使用Java注解来引导Android的Proguard? [英] How to use Java annotations to guide Android's Proguard?

查看:18
本文介绍了如何使用Java注解来引导Android的Proguard?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 Android 上使用 Proguard 时,仅通过反射调用的方法(例如,在 onClick XML 属性中定义的回调)会被错误地剥离.

When using Proguard with Android, methods that are only invoked via reflection (e.g., callbacks defined in onClick XML attributes) are erroneously stripped out.

此问题的一个解决方案是添加每个受影响的类和方法到您的 proguard.cfg.

One solution for this issue is to add each affected class and method to your proguard.cfg.

如何使用Java注解达到同样的效果?

How can I use Java annotations to achieve the same effect?

我觉得这会使代码自我记录,并避免代码和 proguard.cfg 不同步.但是,Android 的 Proguard 似乎并未附带其文档中提到的 annotations.jar.

I feel that would make the code self-documenting and it would avoid code and proguard.cfg drifting out of sync. However, Android's Proguard doesn't seem to ship with the annotations.jar mentioned in its documentation.

推荐答案

您可以检索annotations.jarannotations.pro 来自官方 ProGuard 版本.然后,您应该能够使用 此处

所有必要的选项都可以在 proguard.cfg 中.

All the necessary options can go in proguard.cfg.

这篇关于如何使用Java注解来引导Android的Proguard?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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