小菜今天自己写测试 Demo 时,需要用到 EventBus,目前集成 3.1.1 版本,集成的方式很简单,在某个 Fragment 实践应用中,却一直报入下错:
Caused by: org.greenrobot.eventbus.EventBusException: Subscriber class com.roating.ace.frag.FragmentSign and its super classes have no public methods with the @Subscribe annotation
出问题就解决嘛,尝试如下:
- 检查 EventBus 集成是否添加混淆文件:
-keepattributes *Annotation*
-keepclassmembers class ** {
@org.greenrobot.eventbus.Subscribe <methods>;
}
-keep enum org.greenrobot.eventbus.ThreadMode { *; }
# Only required if you use AsyncExecutor
-keepclassmembers class * extends org.greenrobot.eventbus.util.ThrowableFailureEvent {
<init>(java.lang.Throwable);
}