【问题标题】:EventBus - threadMode not regonized as @Subscribe annotation property :cannot resolve method threadModeEventBus - threadMode 未被识别为 @Subscribe 注释属性:无法解析方法 threadMode
【发布时间】:2019-05-29 20:12:40
【问题描述】:

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

但是,当我写的时候:

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

【问题讨论】:

  • 您介意在您的问题中添加确切的错误消息吗?
  • @fangzhzh,我添加了错误信息;抱歉,我认为编译器无法识别它是直观的。
  • 我怀疑您的项目使用了另一个库,该库也有一个 @subscribe 关键字。当光标在“@Subscriber”并转到定义时,您可以尝试 CMD+B,它会转到 org.greenrobot.eventbu.Subscribe 吗?
  • @fangzhzh 哇,你是对的,不知何故它正在使用 com.google.common.eventbus 代替

标签: android annotations event-bus greenrobot-eventbus greenrobot-eventbus-3.0


【解决方案1】:

我怀疑您的项目使用了另一个库,该库也具有 @Subscribe 关键字。光标在@Subscriber的时候可以试试CMD+B,然后去定义,是去org.greenrobot.eventbu.Subscribe吗?

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-01-26
    • 2021-06-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多