{"record":{"id":"f696404096193ce7","repo":"greenrobot/EventBus","slug":"subscriber-subscriberclass-and-its-super-classe","errorCode":null,"errorMessage":"Subscriber ${subscriberClass} and its super classes have no public methods with the @Subscribe annotation","messagePattern":"Subscriber (.+?) and its super classes have no public methods with the @Subscribe annotation","errorType":"exception","errorClass":"EventBusException","httpStatus":null,"severity":"error","filePath":"EventBus/src/org/greenrobot/eventbus/SubscriberMethodFinder.java","lineNumber":67,"sourceCode":"                           boolean ignoreGeneratedIndex) {\n        this.subscriberInfoIndexes = subscriberInfoIndexes;\n        this.strictMethodVerification = strictMethodVerification;\n        this.ignoreGeneratedIndex = ignoreGeneratedIndex;\n    }\n\n    List<SubscriberMethod> findSubscriberMethods(Class<?> subscriberClass) {\n        List<SubscriberMethod> subscriberMethods = METHOD_CACHE.get(subscriberClass);\n        if (subscriberMethods != null) {\n            return subscriberMethods;\n        }\n\n        if (ignoreGeneratedIndex) {\n            subscriberMethods = findUsingReflection(subscriberClass);\n        } else {\n            subscriberMethods = findUsingInfo(subscriberClass);\n        }\n        if (subscriberMethods.isEmpty()) {\n            throw new EventBusException(\"Subscriber \" + subscriberClass\n                    + \" and its super classes have no public methods with the @Subscribe annotation\");\n        } else {\n            METHOD_CACHE.put(subscriberClass, subscriberMethods);\n            return subscriberMethods;\n        }\n    }\n\n    private List<SubscriberMethod> findUsingInfo(Class<?> subscriberClass) {\n        FindState findState = prepareFindState();\n        findState.initForSubscriber(subscriberClass);\n        while (findState.clazz != null) {\n            findState.subscriberInfo = getSubscriberInfo(findState);\n            if (findState.subscriberInfo != null) {\n                SubscriberMethod[] array = findState.subscriberInfo.getSubscriberMethods();\n                for (SubscriberMethod subscriberMethod : array) {\n                    if (findState.checkAdd(subscriberMethod.method, subscriberMethod.eventType)) {\n                        findState.subscriberMethods.add(subscriberMethod);\n                    }","sourceCodeStart":49,"sourceCodeEnd":85,"githubUrl":"https://github.com/greenrobot/EventBus/blob/0194926b3bcf70cc0d7bfd3c5da16708dd5ab876/EventBus/src/org/greenrobot/eventbus/SubscriberMethodFinder.java#L49-L85","documentation":"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.","triggerScenarios":"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.","commonSituations":"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).","solutions":["Annotate at least one public, non-static method with @org.greenrobot.eventbus.Subscribe taking exactly one event parameter","Add the EventBus ProGuard/R8 keep rules: -keepattributes *Annotation*,Signature and -keepclassmembers class * { @org.greenrobot.eventbus.Subscribe <methods>; }","Verify the import in the subscriber file is org.greenrobot.eventbus.Subscribe","If using the subscriber index (eventbusIndex builder option), ensure the subscriber's module also runs the EventBusAnnotationProcessor and rebuild"],"exampleFix":"// before\npublic class MainActivity extends Activity {\n    public void onMessageEvent(MessageEvent event) { ... } // no annotation\n    // onCreate: EventBus.getDefault().register(this); -> throws\n}\n\n// after\nimport org.greenrobot.eventbus.Subscribe;\n\npublic class MainActivity extends Activity {\n    @Subscribe\n    public void onMessageEvent(MessageEvent event) { ... }\n}","handlingStrategy":"validation","validationCode":"// Fail fast at app start if the default bus has no index and classes will be shrunk\npublic static boolean hasAnnotatedHandler(Class<?> clazz) {\n    for (Method m : clazz.getDeclaredMethods()) {\n        if (m.isAnnotationPresent(Subscribe.class)\n                && Modifier.isPublic(m.getModifiers())\n                && !Modifier.isStatic(m.getModifiers())\n                && m.getParameterCount() == 1) {\n            return true;\n        }\n    }\n    return false;\n}\nif (!hasAnnotatedHandler(MyScreen.class)) {\n    throw new IllegalStateException(\"MyScreen has no usable @Subscribe method\");\n}","typeGuard":null,"tryCatchPattern":"try {\n    EventBus.getDefault().register(this);\n} catch (EventBusException e) {\n    if (String.valueOf(e.getMessage()).contains(\"no public methods with the @Subscribe\")) {\n        Log.e(TAG, \"Missing/misplaced @Subscribe annotation on \" + getClass().getName(), e);\n    } else {\n        throw e;\n    }\n}","preventionTips":["Always import org.greenrobot.eventbus.Subscribe (check IDE auto-imports)","Add a unit test that registers every subscriber class at CI time","Ship EventBus ProGuard keep rules from day one"],"tags":["eventbus","annotation","proguard","registration"],"backgroundTag":null,"analyzedSha":"0194926b3bcf70cc0d7bfd3c5da16708dd5ab876","analyzedAt":"2026-08-14T10:41:08.786Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}