使用EventBus,debug不报错,release版本报错:its super classes have no public methods with the @Subscribe annotat

现该问题是因为未添加 EventBus的混淆,所以在Debug版本中不报错,但是却在Release版本报错;

解决方法:

在混淆文件“proguard-rules.pro”中添加

-keepattributes *Annotation*
-keepclassmembers class ** {
    @org.greenrobot.eventbus.Subscribe ;
}
-keep enum org.greenrobot.eventbus.ThreadMode { *; }


# Only required if you use AsyncExecutor
-keepclassmembers class * extends org.greenrobot.eventbus.util.ThrowableFailureEvent {
    (java.lang.Throwable);
}

你可能感兴趣的:(Android问题)