Caused by: org.greenrobot.eventbus.EventBusException: Subscriber class com.xxx.app.ui.activity
好记性不如烂笔头!!!错误提示:Caused by: org.greenrobot.eventbus.EventBusException: Subscriber class com.xxx.app.ui.activity.WelcomeActivity and its super classes have no public methods with the @Subscribe annota..
·
好记性不如烂笔头!!!
错误提示:Caused by: org.greenrobot.eventbus.EventBusException: Subscriber class com.xxx.app.ui.activity.WelcomeActivity and its super classes have no public methods with the @Subscribe annotation
长时间不开发新项目,你都不知道哪里错了。这里记录一下。 我这里是继承BaseActivity
EventBus在Activity和Fragment的父类里面注册完之后,会报上面的错误, 当时一脸懵逼 ?
之前使用的 2.4.0的版本,没有添加注解也能直接使用。
现在使用的是:implementation 'org.greenrobot:eventbus:3.1.1' 就开始报错了。
其实注册完之后还需要你在父类里面加上@Subscribe注解才可以!
我的解决办法: 在父类中添加EventBus其中的一个函数
@Subscribe
public void onEventMainThread(MessageEvent event) {
}
再运行就没问题了。 记住如果你的Fragment也有父类,记得也要添加并加上注解!
更多推荐
所有评论(0)