如何在Proguard中“保持”课程

时间:2014-05-16 16:58:02

标签: android proguard

我的节目已经

-keep public class * extends android.app.Activity

我遵循的规则将保留所有活动,但标有“Obfuscateable”界面的活动:

 public class SensitiveActivity extends Activity implements Obfuscateable

是否存在否定规则,以便Proguard保留所有活动(第一条规则)减去标有界面Obfuscateable的活动?我的意思是,就像“保持”的对立面一样?

在相关手册部分http://proguard.sourceforge.net/index.html#manual/usage.html中,有一个类规范的模板,但我无法理解:

[@annotationtype] [[!]public|final|abstract|@ ...] [!]interface|class|enum classname
    [extends|implements [@annotationtype] classname]
[{
    [@annotationtype] [[!]public|private|protected|static|volatile|transient ...] <fields> |
                                                                      (fieldtype fieldname);
    [@annotationtype] [[!]public|private|protected|static|synchronized|native|abstract|strictfp ...] <methods> |
                                                                                           <init>(argumenttype,...) |
                                                                                           classname(argumenttype,...) |
                                                                                           (returntype methodname(argumenttype,...));
    [@annotationtype] [[!]public|private|protected|static ... ] *;
    ...
}]

1 个答案:

答案 0 :(得分:0)

ProGuard始终考虑所有保养选项的结合;没有选项可以从中减去。您可以使用标记界面或注释(例如proguard / examples / annotations)标记要保持的活动。

Android构建过程(aapt)会自动写出保存所有导出活动的ProGuard配置,因此在生成活动之后和调用ProGuard之前,您可能需要对其进行修改。