{"record":{"id":"c8090e8cde3624f7","repo":"greenrobot/EventBus","slug":"could-not-find-subscriber-method-in-subscribercl","errorCode":null,"errorMessage":"Could not find subscriber method in ${subscriberClass}. Maybe a missing ProGuard rule?","messagePattern":"Could not find subscriber method in (.+?)\\. Maybe a missing ProGuard rule\\?","errorType":"exception","errorClass":"EventBusException","httpStatus":null,"severity":"error","filePath":"EventBus/src/org/greenrobot/eventbus/meta/AbstractSubscriberInfo.java","lineNumber":75,"sourceCode":"    public boolean shouldCheckSuperclass() {\n        return shouldCheckSuperclass;\n    }\n\n    protected SubscriberMethod createSubscriberMethod(String methodName, Class<?> eventType) {\n        return createSubscriberMethod(methodName, eventType, ThreadMode.POSTING, 0, false);\n    }\n\n    protected SubscriberMethod createSubscriberMethod(String methodName, Class<?> eventType, ThreadMode threadMode) {\n        return createSubscriberMethod(methodName, eventType, threadMode, 0, false);\n    }\n\n    protected SubscriberMethod createSubscriberMethod(String methodName, Class<?> eventType, ThreadMode threadMode,\n                                                      int priority, boolean sticky) {\n        try {\n            Method method = subscriberClass.getDeclaredMethod(methodName, eventType);\n            return new SubscriberMethod(method, eventType, threadMode, priority, sticky);\n        } catch (NoSuchMethodException e) {\n            throw new EventBusException(\"Could not find subscriber method in \" + subscriberClass +\n                    \". Maybe a missing ProGuard rule?\", e);\n        }\n    }\n\n}\n","sourceCodeStart":57,"sourceCodeEnd":81,"githubUrl":"https://github.com/greenrobot/EventBus/blob/0194926b3bcf70cc0d7bfd3c5da16708dd5ab876/EventBus/src/org/greenrobot/eventbus/meta/AbstractSubscriberInfo.java#L57-L81","documentation":"Thrown by AbstractSubscriberInfo.createSubscriberMethod when resolving a method recorded in the generated subscriber index via subscriberClass.getDeclaredMethod(methodName, eventType) fails with NoSuchMethodException. The index (built at compile time by EventBusAnnotationProcessor) stores method name + event type; at runtime EventBus looks the method up reflectively. If the method no longer exists under that exact name/signature — typically because ProGuard/R8 renamed or removed it — the lookup fails and EventBus hints at missing keep rules.","triggerScenarios":"Running a minified/obfuscated Android release build with a subscriber index (addIndex / eventbusIndex in gradle apt arguments) but without ProGuard keep rules for @Subscribe methods and the generated index class; stale index from a previous build referencing renamed methods; manually editing/generating the index with wrong method names.","commonSituations":"Works in debug, crashes in release (R8 renaming onMethod to a); adding the annotation processor and index mid-project; index class itself obfuscated so lookups miss; Gradle apt argument eventbusIndex pointing to an outdated generated class.","solutions":["Add keep rules for annotated methods and the index: -keepattributes *Annotation*,Signature; -keepclassmembers class * { @org.greenrobot.eventbus.Subscribe <methods>; }; -keep class * implements org.greenrobot.eventbus.meta.SubscriberInfoIndex","Clean and rebuild so the generated index matches current method names","Verify the eventbusIndex compiler argument matches the actual generated index class name/package","Reproduce locally by building the minified release variant and checking the mapping.txt for the affected subscriber"],"exampleFix":"# before: release build with index, no keep rules\n# -> EventBusException: Could not find subscriber method in com.app.Foo. Maybe a missing ProGuard rule?\n\n# after: proguard-rules.pro\n-keepattributes *Annotation*,Signature\n-keepclassmembers class ** {\n    @org.greenrobot.eventbus.Subscribe <methods>;\n}\n-keep class * implements org.greenrobot.eventbus.meta.SubscriberInfoIndex","handlingStrategy":"validation","validationCode":"// Debug-mode assertion: every indexed subscriber still exposes its methods\nfor (Method m : subscriberClass.getDeclaredMethods()) {\n    if (m.isAnnotationPresent(Subscribe.class)) {\n        if (!Modifier.isPublic(m.getModifiers())) {\n            throw new IllegalStateException(\"@Subscribe method not public: \" + m);\n        }\n    }\n}","typeGuard":null,"tryCatchPattern":"try {\n    EventBus.getDefault().register(this);\n} catch (EventBusException e) {\n    if (String.valueOf(e.getMessage()).contains(\"Maybe a missing ProGuard rule\")) {\n        Log.e(TAG, \"Index/method mismatch after obfuscation for \" + getClass().getName(), e);\n    }\n    throw e;\n}","preventionTips":["Always ship EventBus keep rules when using the subscriber index in minified builds","Clean-build after method renames so the generated index stays in sync","Test the minified release variant in CI, not just debug"],"tags":["eventbus","subscriber-index","proguard","obfuscation","android","release-build"],"backgroundTag":null,"analyzedSha":"0194926b3bcf70cc0d7bfd3c5da16708dd5ab876","analyzedAt":"2026-08-14T10:41:08.786Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}