greenrobot/EventBus · error · EventBusException

Subscriber ${subscriberClass} and its super classes have no

Error message

Subscriber ${subscriberClass} and its super classes have no public methods with the @Subscribe annotation

What it means

Thrown by SubscriberMethodFinder.findSubscriberMethods when neither the generated subscriber index nor reflection finds any @Subscribe method in the class or its superclasses. register() requires at least one annotated method; an empty result almost always means the methods are missing the annotation, are not public, were removed by shrinking/obfuscation, or the class was expected to be in the generated index but is not.

Source

Thrown at EventBus/src/org/greenrobot/eventbus/SubscriberMethodFinder.java:67

                           boolean ignoreGeneratedIndex) {
        this.subscriberInfoIndexes = subscriberInfoIndexes;
        this.strictMethodVerification = strictMethodVerification;
        this.ignoreGeneratedIndex = ignoreGeneratedIndex;
    }

    List<SubscriberMethod> findSubscriberMethods(Class<?> subscriberClass) {
        List<SubscriberMethod> subscriberMethods = METHOD_CACHE.get(subscriberClass);
        if (subscriberMethods != null) {
            return subscriberMethods;
        }

        if (ignoreGeneratedIndex) {
            subscriberMethods = findUsingReflection(subscriberClass);
        } else {
            subscriberMethods = findUsingInfo(subscriberClass);
        }
        if (subscriberMethods.isEmpty()) {
            throw new EventBusException("Subscriber " + subscriberClass
                    + " and its super classes have no public methods with the @Subscribe annotation");
        } else {
            METHOD_CACHE.put(subscriberClass, subscriberMethods);
            return subscriberMethods;
        }
    }

    private List<SubscriberMethod> findUsingInfo(Class<?> subscriberClass) {
        FindState findState = prepareFindState();
        findState.initForSubscriber(subscriberClass);
        while (findState.clazz != null) {
            findState.subscriberInfo = getSubscriberInfo(findState);
            if (findState.subscriberInfo != null) {
                SubscriberMethod[] array = findState.subscriberInfo.getSubscriberMethods();
                for (SubscriberMethod subscriberMethod : array) {
                    if (findState.checkAdd(subscriberMethod.method, subscriberMethod.eventType)) {
                        findState.subscriberMethods.add(subscriberMethod);
                    }

View on GitHub (pinned to 0194926b3b)

Solutions

  1. Annotate at least one public, non-static method with @org.greenrobot.eventbus.Subscribe taking exactly one event parameter
  2. Add the EventBus ProGuard/R8 keep rules: -keepattributes *Annotation*,Signature and -keepclassmembers class * { @org.greenrobot.eventbus.Subscribe <methods>; }
  3. Verify the import in the subscriber file is org.greenrobot.eventbus.Subscribe
  4. If using the subscriber index (eventbusIndex builder option), ensure the subscriber's module also runs the EventBusAnnotationProcessor and rebuild

Example fix

// before
public class MainActivity extends Activity {
    public void onMessageEvent(MessageEvent event) { ... } // no annotation
    // onCreate: EventBus.getDefault().register(this); -> throws
}

// after
import org.greenrobot.eventbus.Subscribe;

public class MainActivity extends Activity {
    @Subscribe
    public void onMessageEvent(MessageEvent event) { ... }
}
Defensive patterns

Strategy: validation

Validate before calling

// Fail fast at app start if the default bus has no index and classes will be shrunk
public static boolean hasAnnotatedHandler(Class<?> clazz) {
    for (Method m : clazz.getDeclaredMethods()) {
        if (m.isAnnotationPresent(Subscribe.class)
                && Modifier.isPublic(m.getModifiers())
                && !Modifier.isStatic(m.getModifiers())
                && m.getParameterCount() == 1) {
            return true;
        }
    }
    return false;
}
if (!hasAnnotatedHandler(MyScreen.class)) {
    throw new IllegalStateException("MyScreen has no usable @Subscribe method");
}

Try / catch

try {
    EventBus.getDefault().register(this);
} catch (EventBusException e) {
    if (String.valueOf(e.getMessage()).contains("no public methods with the @Subscribe")) {
        Log.e(TAG, "Missing/misplaced @Subscribe annotation on " + getClass().getName(), e);
    } else {
        throw e;
    }
}

Prevention

When it happens

Trigger: Calling register() on an object whose onEvent* / @Subscribe methods were stripped by ProGuard/R8 (no keep rules); annotating with the wrong Subscribe import (e.g. another library's @Subscribe or io.reactivex subjects bus); methods declared private/protected/static; using the annotation processor index while the subscriber class is outside the compiled source sets covered by the processor.

Common situations: Release builds without EventBus ProGuard rules; importing Subscribe from a different package (IDE auto-import mistake); registering base classes whose only handlers live in a subclass; adding EventBus to an existing codebase with onEvent methods but no annotations (EventBus 2.x style without upgrading to 3.x annotations).

Related errors


AI-assisted analysis of greenrobot/EventBus@0194926b3b (2026-08-14). Data as JSON: /api/errors/f696404096193ce7. Report an issue: GitHub.