AriesHoo / FastLib

一个Android项目级快速开发框架,节约大部分写常用功能时间以实现更多项目业务功能及体验上的优化。使用说明见wiki
https://github.com/AriesHoo/FastLib/wiki
Apache License 2.0
492 stars 95 forks source link

将simpleEventbus替换后,启动应用就报its super classes have no public methods with the @Subscribe annotation #50

Closed wangsong1991 closed 4 years ago

wangsong1991 commented 4 years ago

这是什么原因,我用到eventbus的方法都用了权限public,所有用到的地方都出现这个问题,如果在该类中加上@Subscribe(threadMode = ThreadMode.MAIN) public void getEventBus(Integer integer) {} 就都不报错了,但是不能所有的都加这个呀,能给出个解决办法吗?网上都是让加注解+public,这些我都加了

AriesHoo commented 4 years ago

你是用的哪个版本?还有在最新的版本里eventbus没有被导入需要自己引入。还有就是你使用FastLib的demo有没有问题

wangsong1991 commented 4 years ago

我知道 我用的2.3.4 我自己导入了eventbus,替换simple.evenbus后,就显示这个问题,不知道是我的原因还是说替换出错了,

wangsong1991 commented 4 years ago

demo是没有问题的

AriesHoo commented 4 years ago

你是想用 org.greenrobot:eventbus:3.1.1 这个eventbus嘛

wangsong1991 commented 4 years ago

wangsong1991 commented 4 years ago

我看git上的用法 跟之前没有什么区别呀,所以我就替换了升级了一下版本

AriesHoo commented 4 years ago

你要在对应的Activity里定义public methods with the @Subscribe annotation 如图 image 我之前一直用的是AndroidEventBus没实际弄过EventBus。后面版本会将 isEventBusEnable 默认返回false 不使用EventBus的Activity得手动将isEventBusEnable 设置成false不然就会出现你说的那个问题,后续版本会进行调整

wangsong1991 commented 4 years ago

image 哦 那就麻烦了我这里 用的地方不多,不用的地方那就数不过来了 那我先不用eventbus

AriesHoo commented 4 years ago

可以用AndroidEventBus先

wangsong1991 commented 4 years ago

image androideventbus不会受影响是吗?

wangsong1991 commented 4 years ago

AndroidEventBus现在不维护了

wangsong1991 commented 4 years ago

现在是2.3.2以上版本 添加依赖后就会出现在这个问题

wangsong1991 commented 4 years ago

添加了androideventbus也不管用,该怎么弄?

AriesHoo commented 4 years ago

AndroidEventBus功能目前是够用了的。我项目里一直在用,添加了AndroidEventBus要去掉EventBus、归根到底 1、添加了EventBus的在所有的Activity添加public methods with the @subscribe annotation或者 2、不需要EventBus的Activity isEventBusEnable返回false不执行注册操作即可 后续我将isEventBusEnable默认返回false

AriesHoo commented 4 years ago

2.3.5版本做了修复。可以用正常使用EventBus不做其它设置即可