EventBusException: Subscriber class *** and its super classes have no public methods with the @Subsc
来源:互联网 发布:vr全景拼接软件 编辑:程序博客网 时间:2024/05/21 09:47
简述:
去年的时候使用过一次EventBus,今天又遇到使用EventBus的项目,由于时隔一年多了所以写了一个Demo,但不行的是按照往常的用法却报出了这个异常:
EventBusException: Subscriber class *** and its super classes have no public methods with the @Subscribe annotation。说明一下,我用的是3.0.0版本的EventBus。
异常日志:
ava.lang.RuntimeException: Unable to start activity ComponentInfo{com.lizhenya.eventbusdemo/com.lizhenya.eventbusdemo.MainActivity}: org.greenrobot.eventbus.EventBusException: Subscriber class com.lizhenya.eventbusdemo.MainActivity and its super classes have no public methods with the @Subscribe annotationat android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2416)at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)at android.app.ActivityThread.-wrap11(ActivityThread.java)at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)at android.os.Handler.dispatchMessage(Handler.java:102)at android.os.Looper.loop(Looper.java:148)at android.app.ActivityThread.main(ActivityThread.java:5417)at java.lang.reflect.Method.invoke(Native Method)at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)Caused by: org.greenrobot.eventbus.EventBusException: Subscriber class com.lizhenya.eventbusdemo.MainActivity and its super classes have no public methods with the @Subscribe annotationat org.greenrobot.eventbus.SubscriberMethodFinder.findSubscriberMethods(SubscriberMethodFinder.java:67)at org.greenrobot.eventbus.EventBus.register(EventBus.java:136)at com.lizhenya.eventbusdemo.MainActivity.onCreate(MainActivity.java:24)at android.app.Activity.performCreate(Activity.java:6237)at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1107)at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2369)at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476) at android.app.ActivityThread.-wrap11(ActivityThread.java) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:148) at android.app.ActivityThread.main(ActivityThread.java:5417) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
分析:
在使用EventBus中在消息接收的页面需要使用下面的代码来注册:
EventBus.getDefault().register(this)onCreate时,EventBus扫描当前类,将onEventMainThread()等以onEvent开头的几个方法存储起来。OK,那么既然可以扫描出来为什么还会报出这样的异常错误,这个问题还得看源码。
解决方案:
在onEventMainThread()方法上加注解“@Subscribe”;
0 0
- EventBusException: Subscriber class *** and its super classes have no public methods with the @Subsc
- EventBusException: Subscriber class *** and its super classes have no public methods with the @Subsc
- EventBusException: Subscriber class *** and its super classes have no public methods with the @Subsc
- Subscriber class xxx.xxx.xxx and its super classes have no public methods with the@Subscribe annotat
- Subscriber class xxx.xxx.xxx and its super classes have no public methods with the@Subscribe annotat
- 异常 EventBusException:its super classes have no public methods with the @Subscribe annotation
- 异常 EventBusException:its super classes have no public methods with the @Subscribe annotation
- Subscriber class .NewsFragment and its super classes have no public methods
- EventBus报错:and its super classes have no public methods with the @Subscribe annotation
- MainActivity and its super classes have no public methods with the @Subscribe annotation
- 关于eventbus报错its super classes have no public methods with the @Subscribe的问题
- 使用EventBus框架报异常:its super classes have no public methods with the @Subscribe annotation
- EventBus3.0报错..its super classes have no public methods with the @Subscribe annotation
- Eventbus注册异常:its super classes have no public methods with the @Subscribe annotation
- AndroidStudio关于EventBus报错解决方法its super classes have no public methods with the @Subscribe
- 【Android】AndroidStudio关于EventBus报错解决方法its super classes have no public methods with the @Subscribe
- EventBus 注册错误no public methods with the @Subscribe annotation
- Container Class and its equals(), hashCode() methods
- 各种排序算法时间复杂度和空间复杂度表
- HDU1548:A strange lift(BFS)
- VC维理论
- Spark中repartition和coalesce的用法
- YOLO源码解析之yolo.c
- EventBusException: Subscriber class *** and its super classes have no public methods with the @Subsc
- eclipse使用心得
- 关于python的PE库pefile
- jquery-ui.min.js:5 Uncaught TypeError: b.nodeName.toLowerCase is not a function
- mysql事务应用
- 机器学习读书笔记(集成学习Boosting方法)
- 趣味100道C语言程序题num three
- 像素横纵比公式的原理
- Eclipse下Python的MySQLdb的安装以及相关问题