Eventbus: org.greenrobot.eventbus.EventBusException: Subscriber class XXX and its super classes have no public methods with the @Subscribe annotation

Created on 5 Aug 2016  ·  12Comments  ·  Source: greenrobot/EventBus

I'm trying to use EventBus in my project, but I'm stuck with a strange exception thrown by EventBus when trying to get my App running.

The case is I'm using EventBus in a custom view where I register EventBus in the onAttachToWindow() method and unregister it in the onDetachFromWindow() method. And then I created a method like this:

@Subscribe(threadMode = ThreadMode.MAIN)
public void onEventReceived(MessageEvent event) {
    //TODO
}

The problem is when I run the App, an exception is thrown which is really weird:
org.greenrobot.eventbus.EventBusException: Subscriber class XXX and its super classes have no public methods with the @Subscribe annotation

Can anyone help with this? Any suggestions is welcomed.

Most helpful comment

Have you removed those methods using Proguard perhaps?

All 12 comments

Have you removed those methods using Proguard perhaps?

Suggest first make sure the order of the event's coming and the registering is right

@william-ferguson-au Yes, Proguard is the cause, after modify the Proguard config, it's working now. Thanks!

@van048 Thanks, the problem is solved now.

I alse meet this problem and don not know how to resolve .Can you teach me how to resolve this problem? Thank you !

@wuzhaohui026 Please refer to this link : http://greenrobot.org/eventbus/documentation/proguard/

Just follow the instructions and you will be set, welcome to come back to me for any further issues.

Thank you . But i didn't do ProGuard obfuscates method.And I have tryed but also hava problems

@wuzhaohui026 Are you sure your problem is identical with mine? What the is procedure of you trying to integrate EventBus?

OK。I have resolve my problem. I make a mistake.Thank you for your help.(PS:in fact ,i'm not good at English,ha ha.)

@wuzhaohui026 Glad you solved it.

i am having same issue and i have written the proguard rules given in documentation though the error persists and i am using androidx.

Kindly suggest the solution.

@harshsingh98 Please share more details in #586.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

liaohuyu picture liaohuyu  ·  4Comments

cckroets picture cckroets  ·  16Comments

lordcodes picture lordcodes  ·  3Comments

ANewAnonymous picture ANewAnonymous  ·  4Comments

onomated picture onomated  ·  12Comments