So, my app exchanges messages from/to my MainActivity to/from a background Service and I used EventBus to handle that. I'm registering both components with
EventBus.getDefault().register(this);
on their onCreates. And I'm sending/receiving an event with:
EventBus.getDefault().post(new MyMessagePojo("message"));
and
public void onEvent(MyMessagePojo event) { ... }
Everything works well when I run the project from my AndroidStudio right to my test phone. However, when I generated the signed APK I installed the app and got a crash with the following exception:
Subscriber class my.package.MainActivity has no public methods called onEvent
Where it clearly has. I tried changing it from onEvent
to onEventMainThread
in my MainActivity but with no success. It's pretty frustrating since I was about to publish the app and now I can't fix this problem.
I've been through this and this but they were of no help.
Any ideas?
This is is addressed in the EventBus HOWTO docs. https://github.com/greenrobot/EventBus/blob/master/HOWTO.md
Use the below code to keep only the onEvent functions.