我怎么能告诉ProGuard的维持我的功能是用于的onClick? [英] How can I tell ProGuard to keep my function that is used for onClick?

查看:109
本文介绍了我怎么能告诉ProGuard的维持我的功能是用于的onClick?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我现在用的是安卓的onClick 属性附加伤害我​​的一些布局的.xml文件,我的Andr​​oid应用程序,但ProGuard的去除我的code时,这些方法它运行,因为没有在我的code是不断打电话给他们。

I am using the android:onClick atribute in some of my .xml layout files for my android application, but ProGuard is removing these methods from my code when it runs because nothing in my code is ever calling them.

相反则指定每个函数分别,我想他们的名字像 listener_functionName ,并使用通配符,像 -keep监听器_ * (我知道这是不正确的,但希望它说明我的目标)。

Rather then specifying each function individually, I would like to name them something like listener_functionName, and use wildcards, like -keep listener_* (I know this is incorrect, but hopefully it illustrates my goal).

如果这是可能的,这将是巨大的,但如果没有我还需要知道如何在proguard.cfg文件中指定这些功能。任何帮助是AP preciated。

If this is possible that would be great, but if not I still need to know how to specify these functions in the proguard.cfg file. Any help is appreciated.

推荐答案

根据 ProGuard的文档:

字段和方法也可   使用常规的前pressions规定。   名称可以包含以下   通配符:匹配任何单   字符的方法名称。   *任何部分的方法名称相匹配。

Fields and methods may also be specified using regular expressions. Names can contain the following wildcards: ? matches any single character in a method name. * matches any part of a method name.

所以,你会发现指定

-keep class com.example.MyClass {
  public void listener_*(android.view.View);
}

在你的ProGuard的标志。

in your proguard flags.

这篇关于我怎么能告诉ProGuard的维持我的功能是用于的onClick?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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