事件总线 - 线程模式未重新定位为@Subscribe注释属性:无法解析方法线程模式



我正在使用GreenRobot EventBus,我想定义一些线程属性,根据文档,

但是,当我写:

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

我收到一个错误,编译器指定方法无法识别线程模式:cannot resolve method 'threadMode'

我的gradle文件上有:

implementation 'org.greenrobot:eventbus:3.1.1'

我怀疑您的项目使用了另一个也具有@Subscribe关键字的库。当光标在@Subscriber中并转到定义时,您可以尝试CMD + B吗,它会转到org.greenrobot.eventbu.Subscribe吗?

这里的要点是:当错误cannot resolve method发生时,您可以随时转到定义以检查那里发生了什么:)

最新更新