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,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

简述:

    去年的时候使用过一次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 annotation  
at 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 annotation  
at 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)   

解决方案:

    在onEventMainThread()方法上加注解“@Subscribe”;


Android学习交流群:523487222

(如果您觉得有用,欢迎加入,一起学习进步)
点击链接加入群【Android学习群】




解决方案:

    在onEventMainThread()方法上加注解“@Subscribe”;

这篇关于EventBusException: Subscriber class *** and its super classes have no public methods with the @Subsc的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/322918

相关文章

DBeaver 连接 MySQL 报错 Public Key Retrieval is not allowed

DBeaver 连接 MySQL 报错 Public Key Retrieval is not allowed 文章目录 DBeaver 连接 MySQL 报错 Public Key Retrieval is not allowed问题解决办法 问题 使用 DBeaver 连接 MySQL 数据库的时候, 一直报错下面的错误 Public Key Retrieval is

类型信息:反射-Class

在说反射前提一个概念:RTTI(在运行时,识别一个对象的类型) public class Shapes {public static void main(String[] args) {List<Shape> shapes = Arrays.asList(new Circle(), new Square(), new Triangle());for (Shape shape : shapes

react笔记 8-17 属性绑定 class绑定 引入图片 循环遍历

1、绑定属性 constructor(){super()this.state={name:"张三",title:'我是一个title'}}render() {return (<div><div>aaaaaaa{this.state.name}<div title={this.state.title}>我是一个title</div></div></div>)} 绑定属性直接使用花括号{}   注

问:Super与this在Java中有什么区别?

this: this 关键字用于引用当前对象。它通常用于区分成员变量和方法参数或局部变量。在实例方法中,this 指向调用该方法的对象。在构造函数中,this 指向正在被初始化的对象。 super: super 关键字用于引用父类(超类)的构造函数、方法或变量。在子类的构造函数中,super() 用于调用父类的构造函数。在子类的方法中,super.methodName() 用于调用父类的方法。

Unity 资源 之 Super Confetti FX:点亮项目的璀璨粒子之光

Unity 资源 之 Super Confetti FX:点亮项目的璀璨粒子之光 一,前言二,资源包内容三,免费获取资源包 一,前言 在创意的世界里,每一个细节都能决定一个项目的独特魅力。今天,要向大家介绍一款令人惊艳的粒子效果包 ——Super Confetti FX。 二,资源包内容 💥充满活力与动态,是 Super Confetti FX 最显著的标签。它宛如一位

MTK Android P/Q system/vendor/super快速打包

一、Android 新版本默认开启了动态分区,把system vendor  product等分区打包成一个super分区。这对于我们使用替换分区的方法来排查问题不是很方便,直接替换一个super也不知道到底是哪个部分导致的。所以我们需要自己制作super.img来缩小范围。下面讲讲如何快速生成system、vendor、super,以及vbmeta(校验image,不匹配可能会导致不开机) 二

? extends T 和 ? super T分别是什么意思?有什么不同?

<? extends T>首先你很容易误解它为继承于T的所有类的集合,这是大错特错的,相信能看下去你一定见过或用过List<? extends T>吧?为什么我说理解成一个集合是错呢?如果理解成一个集合那为什么不用List<T>来表示?所以<? extends T>不是一个集合,而是T的某一种子类的意思,记住是一种,单一的一种,问题来了,由于连哪一种都不确定,带来了不确定性,所以是不可能通过add

泛型参Class、Class、Class的对比区别

1.原文链接 泛型参Class、Class、Class的对比区别 https://blog.csdn.net/jitianxia68/article/details/73610606 <? extends T>和<? super T> https://www.cnblogs.com/drizzlewithwind/p/6100164.html   2.具体内容: 泛型参数Class、

【VueJS】深入理解 computed 和 methods 方法

前言   模板内的表达式是非常便利的,但是它们实际上只用于简单的运算。在模板中放入太多的逻辑会让模板过重且难以维护。例如: <div id="example">{{ message.split('').reverse().join('') }}</div> computed 方法   所以引入了计算属性computed,将复杂的逻辑放入计算中进行处理,同时computed有缓存功能,

java基础总结11-面向对象7(super关键字)

在JAVA类中使用super来引用父类的成分,用this来引用当前对象,如果一个类从另外一个类继承,我们new这个子类的实例对象的时候,这个子类对象里面会有一个父类对象。怎么去引用里面的父类对象呢?使用super来引用,this指的是当前对象的引用,super是当前对象里面的父对象的引用。 1 super关键字测试 package cn.galc.test;/*** 父类* @autho