androidannotationsevent-busgreenrobot-eventbusgreenrobot-eventbus-3.0

EventBus - threadMode not regonized as @Subscribe annotation property :cannot resolve method threadMode


I am using GreenRobot EventBus , I wanted to define some Threading properties, according to docs,

However, when I write:

 @Subscribe(threadMode = ThreadMode.MAIN)
    public void onShowNotification(NotificationEvent event) {
        if(event == NotificationEvent.bannerEvent) {
            updateContents();
        }
    }

I get an error that threadMode is not recognized by compiler specifying method: cannot resolve method 'threadMode'

i have on my gradle file:

implementation 'org.greenrobot:eventbus:3.1.1'

Solution

  • I suspect that your project uses another library which also has a @Subscribe keyword. Can you try CMD+B when the cursor in the @Subscriber and go to the definition, does it go to org.greenrobot.eventbu.Subscribe?

    The takeaway here: when error cannot resolve method happens, you can always go to the definition to check what happens there :)