Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
PanWangJ opened this issue Aug 5, 2016 · 12 comments

Comments

@PanWangJ
Copy link

PanWangJ commented Aug 5, 2016

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.

@william-ferguson-au
Copy link
Contributor

Have you removed those methods using Proguard perhaps?

@van048
Copy link

van048 commented Aug 5, 2016

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

@PanWangJ
Copy link
Author

PanWangJ commented Aug 5, 2016

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

@PanWangJ
Copy link
Author

PanWangJ commented Aug 5, 2016

@van048 Thanks, the problem is solved now.

@PanWangJ PanWangJ closed this as completed Aug 5, 2016
@Cai-Go
Copy link

Cai-Go commented Sep 8, 2016

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

@PanWangJ
Copy link
Author

PanWangJ commented Sep 8, 2016

@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.

@Cai-Go
Copy link

Cai-Go commented Sep 8, 2016

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

@PanWangJ
Copy link
Author

PanWangJ commented Sep 8, 2016

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

@Cai-Go
Copy link

Cai-Go commented Sep 8, 2016

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.)

@PanWangJ
Copy link
Author

@wuzhaohui026 Glad you solved it.

@harshsingh98
Copy link

harshsingh98 commented Jan 2, 2020

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.

@greenrobot-team
Copy link
Collaborator

@harshsingh98 Please share more details in #586.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants