Proguard 绿色机器人事件总线

Proguard green robot event bus

我在我的应用程序上使用事件总线。在 docs 之后我添加了

# Green Robot Eventbus
-keepattributes *Annotation*
-keepclassmembers class ** {
    @org.greenrobot.eventbus.Subscribe <methods>;
}
-keep enum org.greenrobot.eventbus.ThreadMode { *; }

给我的 <project>/app/proguard-rules.pro

但是编译我的应用时总是报错

ava.lang.RuntimeException: Unable to start activity ComponentInfo{com.rkmax.myapp.MyActivity}:  org.greenrobot.eventbus.e: Subscriber class com.rkmax.myapp.MyActivity and its super classes have no public methods with the @Subscribe annotation

我的应用程序在调试版本上运行良好。也许这是我所缺少的东西

我所有的 Subscribe-annotated 方法都被定义为 void methodName(...) 我发现我必须显式添加 public 才能在发布版本上正常工作