EventBus icon indicating copy to clipboard operation
EventBus copied to clipboard

EventBus.getDefault (). Isregistered (this) method is invalid

Open hanfeiyu1 opened this issue 4 years ago • 1 comments

Eventbus.getdefault ().isregistered (this) returns false when plug-in APK (loaded by classLoader) USES eventbus.getdefault ().isregistered (this) to determine if EventBus isregistered, even if I have registered previously.

hanfeiyu1 avatar Jul 14 '20 00:07 hanfeiyu1

Have a look at the source code what might be the issue. You might also provide an example project reproducing this.

greenrobot-team avatar Jul 14 '20 05:07 greenrobot-team

` public void register(Object subscriber) { if (AndroidDependenciesDetector.isAndroidSDKAvailable() && !AndroidDependenciesDetector.areAndroidComponentsAvailable()) { // Crash if the user (developer) has not imported the Android compatibility library. throw new RuntimeException("It looks like you are using EventBus on Android, " + "make sure to add the "eventbus" Android library to your dependencies."); }

    Class<?> subscriberClass = subscriber.getClass();
    List<SubscriberMethod> subscriberMethods = subscriberMethodFinder.findSubscriberMethods(subscriberClass);
    Collections.sort(subscriberMethods);
    synchronized (this) {
        for (SubscriberMethod subscriberMethod : subscriberMethods) {
            subscribe(subscriber, subscriberMethod);
        }
    }
}`

look at this code,maybe it 's because there 's no @subscribe method in your registered class.so it won't execute the subscribe method

tomridder avatar Mar 15 '23 16:03 tomridder

The original poster has not replied in a long time. Closing this.

greenrobot-team avatar Mar 27 '23 12:03 greenrobot-team