【问题标题】:proguard configuration with groundy Tasks带有接地任务的 proguard 配置
【发布时间】:2013-12-29 11:31:04
【问题描述】:

我正在使用包含 GroundTask 类的 android“Groundy”库,该类使用注释。此外,我创建了一个类

public class DownloadTask extends GroundyTask

还有一个回调对象:

  private final Object mCallback = new Object() {
    @OnProgress(DownloadTask.class)
    public void onNiceProgress(@Param(Groundy.PROGRESS) int progress) {
        mProgressDialog.setProgress(progress);
    }
....

但是在使用 proguard 进行混淆后,使用“OnProgress”注释的方法永远不会被调用(但不会发生错误)

在我添加的proguard文件中

-keep class com.telly.groundy.*** {
public protected private *;
}
-keepattributes *Annotation*, EnclosingMethod
-keepattributes *OnSuccess*
-keepattributes *OnProgress*
-keepattributes *OnCancel*
-keepattributes *OnCallback*
-keepattributes *OnFailure*
-keepattributes *OnStart*
-keepattributes *Param*
-keepattributes *Traverse*

-keep class com.my.namespace.DownloadTask {
 public protected private *;
}

知道这里可能缺少哪些“保留”配置吗?

【问题讨论】:

  • 你好@fritz 我也有同样的问题。你得到答案了吗?
  • 不,我决定不再使用它了。

标签: android annotations proguard groundy


【解决方案1】:

我刚刚在自述文件中添加了一个基本的 proguard 配置。它看起来像这样:

-keepattributes *Annotation*

-keepclassmembers,allowobfuscation class * {
    @com.telly.groundy.annotations.* *;
    <init>();
}

-keepnames class com.telly.groundy.generated.*
-keep class com.telly.groundy.generated.*
-keep class com.telly.groundy.ResultProxy
-keepnames class * extends com.telly.groundy.ResultProxy
-keep class * extends com.telly.groundy.GroundyTask

【讨论】:

    【解决方案2】:

    ProGuard 不知道代码通过反射访问注解,因此您可能需要显式保存它:

    -keep @interface com.telly.groundy.annotations.OnProgress
    

    【讨论】:

      猜你喜欢
      • 2012-05-15
      • 1970-01-01
      • 2013-01-31
      • 1970-01-01
      • 1970-01-01
      • 2012-02-25
      • 2014-06-03
      • 1970-01-01
      • 2013-07-11
      相关资源
      最近更新 更多