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

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

问题描述

在使用Proguard的采用Android,这是通过反射仅调用的方法(例如,在XML的onClick定义回调属性)被错误地剥离出来。

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?

我觉得这将使code自文档,这将避免code和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.

推荐答案

您可以从官方ProGuard的发布检索annotations.jar和annotations.pro。然后,您应该能够使用注释作为讨论

You can retrieve annotations.jar and annotations.pro from an official ProGuard release. You should then be able to use annotations as discussed in

<一个href="http://proguard.sourceforge.net/manual/examples.html#annotated">http://proguard.sourceforge.net/manual/examples.html#annotated

所有必要的选项可以进去proguard.cfg。

All the necessary options can go in proguard.cfg.

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

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