title: AndroidAnnotations and EventBus
body: <p>I have an annotated Activity in a library, which is a subscriber to an EventBus event from the same library. It looks something like this, greatly simplified:</p>
  
  <pre><code>@EActivity(resName = "activity_foo")
  public class Foo extends Activity {
  
      public void onEvent(BarEvent event){
          doSomething();
      }
  }
  </code></pre>
  
  <p>It should work according to this:</p>
  
  <p><a href="http://timnew.me/blog/2014/09/14/otto-and-android-annotations-compatibility-issue-analysis/">http://timnew.me/blog/2014/09/14/otto-and-android-annotations-compatibility-issue-analysis/</a></p>
  
  <p>But in fact it returns with this error:</p>
  
  <blockquote>
    <p>Unable to start activity ... de.greenrobot.event.EventBusException:
    Subscriber class com.foo.bar.activities.Foo_ has no public methods
    called onEvent</p>
  </blockquote>
  
  <p>It seems EventBus doesn't look in the parent class. I guess the @Subscribe annotation everybody is talking about is only in Guava and Otto, but not in EventBus. Nobody is talking about compatibility problems between AA and Eventbus on the net, so I must be missing something.</p>
  
  <p>How can I make this work?</p>
  
  <p>EventBus: 2.4</p>
  
  <p>AA: 3.2</p>
  
  <p><strong>EDIT</strong>:</p>
  
  <p>After WonderCsabo's answer I updated EventBus to 3.0 beta (including Subscribe annotations) and AA to 3.3.1 and the problem is gone, but there is another one:</p>
  
  <pre><code>   java.lang.NoSuchFieldError
              at libcore.reflect.AnnotationAccess.decodeValue(AnnotationAccess.java:688)
              at libcore.reflect.AnnotationAccess.getDefaultValue(AnnotationAccess.java:361)
              at java.lang.reflect.Method.getDefaultValue(Method.java:327)
              at libcore.reflect.AnnotationFactory.getElementsDescription(AnnotationFactory.java:75)
              at libcore.reflect.AnnotationFactory.&lt;init&gt;(AnnotationFactory.java:112)
              at libcore.reflect.AnnotationFactory.createAnnotation(AnnotationFactory.java:94)
              at libcore.reflect.AnnotationAccess.toAnnotationInstance(AnnotationAccess.java:666)
              at libcore.reflect.AnnotationAccess.toAnnotationInstance(AnnotationAccess.java:641)
              at libcore.reflect.AnnotationAccess.getDeclaredAnnotation(AnnotationAccess.java:170)
              at java.lang.reflect.Method.getAnnotation(Method.java:301)
              at de.greenrobot.event.n.b(SourceFile:133)
              at de.greenrobot.event.n.a(SourceFile:79)
              at de.greenrobot.event.c.a(SourceFile:135)
              at com.babestudios.lib.lq.activities.f.onStart(SourceFile:515)
              at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1236)
              at android.app.Activity.performStart(Activity.java:6006)
              at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2288)
              at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2387)
              at android.app.ActivityThread.access$800(ActivityThread.java:151)
              at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1303)
              at android.os.Handler.dispatchMessage(Handler.java:102)
              at android.os.Looper.loop(Looper.java:135)
              at android.app.ActivityThread.main(ActivityThread.java:5254)
              at java.lang.reflect.Method.invoke(Native Method)
              at java.lang.reflect.Method.invoke(Method.java:372)
              at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
              at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)
       Caused by: java.lang.NoSuchFieldException: PostThread
              at java.lang.Class.getDeclaredField(Class.java:890)
              at libcore.reflect.AnnotationAccess.decodeValue(AnnotationAccess.java:685)
              at libcore.reflect.AnnotationAccess.getDefaultValue(AnnotationAccess.java:361)
              at java.lang.reflect.Method.getDefaultValue(Method.java:327)
              at libcore.reflect.AnnotationFactory.getElementsDescription(AnnotationFactory.java:75)
              at libcore.reflect.AnnotationFactory.&lt;init&gt;(AnnotationFactory.java:112)
              at libcore.reflect.AnnotationFactory.createAnnotation(AnnotationFactory.java:94)
              at libcore.reflect.AnnotationAccess.toAnnotationInstance(AnnotationAccess.java:666)
              at libcore.reflect.AnnotationAccess.toAnnotationInstance(AnnotationAccess.java:641)
              at libcore.reflect.AnnotationAccess.getDeclaredAnnotation(AnnotationAccess.java:170)
              at java.lang.reflect.Method.getAnnotation(Method.java:301)
              at de.greenrobot.event.n.b(SourceFile:133)
              at de.greenrobot.event.n.a(SourceFile:79)
              at de.greenrobot.event.c.a(SourceFile:135)
              at com.babestudios.lib.lq.activities.f.onStart(SourceFile:515)
              at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1236)
              at android.app.Activity.performStart(Activity.java:6006)
              at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2288)
              at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2387)
              at android.app.ActivityThread.access$800(ActivityThread.java:151)
              at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1303)
              at android.os.Handler.dispatchMessage(Handler.java:102)
              at android.os.Looper.loop(Looper.java:135)
              at android.app.ActivityThread.main(ActivityThread.java:5254)
              at java.lang.reflect.Method.invoke(Native Method)
              at java.lang.reflect.Method.invoke(Method.java:372)
              at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
              at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)
  </code></pre>
  
  <p>And I noticed that both problems (the missing onEvent and now the PostThread is only a problem on the release version. I use ProGuard with the recommended exceptions for EventBus and AA).</p>
  
  <p><strong>EDIT 2</strong>:</p>
  
  <p>I added</p>
  
  <pre><code>-keep class de.greenrobot.** {*;}
  </code></pre>
  
  <p>and it seems to be working.</p>