ProGuard configuration of greenrobot event bus

1.9k Views Asked by At

I'm using eventbus into my application and it's working fine on debuge mode but not working on release APK.

Following code used for ProGuard configuration :

  -keepattributes *Annotation*
  -keepclassmembers class ** {
    @org.greenrobot.eventbus.Subscribe <methods>;
   }
  -keep enum org.greenrobot.eventbus.ThreadMode { *; }

All my Subscribe-annotated methods are also public

Logcat output :

Could not dispatch event: class com.dhaval.example.model.entity.response.DashboardUnreadStoryResponse to subscribing class class com.dhaval.example.view.activity.MainActivity java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String com.dhaval.example.model.entity.Dashboard.b.a()' on a null object reference at com.dhaval.example.view.activity.MainActivity.b(SourceFile:150) at com.dhaval.example.view.activity.MainActivity.onEventBusEvent(SourceFile:560) at java.lang.reflect.Method.invoke(Native Method) at org.greenrobot.eventbus.c.a(SourceFile:485) at org.greenrobot.eventbus.c.a(SourceFile:420) at org.greenrobot.eventbus.c.a(SourceFile:397) at org.greenrobot.eventbus.c.a(SourceFile:370) at org.greenrobot.eventbus.c.d(SourceFile:251) at com.dhaval.example.view.a.r$1.a(SourceFile:140) at com.dhaval.example.view.a.r$1.a(SourceFile:130) at com.dhaval.example.f.ap$2.a(SourceFile:90) at com.dhaval.example.f.ap$2.a(SourceFile:85) at com.dhaval.example.network.a$1.a_(SourceFile:101) at rx.c.a.a_(SourceFile:134) at rx.internal.operators.n$a.a(SourceFile:224) at rx.a.b.b$b.run(SourceFile:107) at android.os.Handler.handleCallback(Handler.java:751) at android.os.Handler.dispatchMessage(Handler.java:95) at android.os.Looper.loop(Looper.java:154) at android.app.ActivityThread.main(ActivityThread.java:6290) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776) 07-14 11:39:43.640 16402-16402/com.dhaval.example D/EventBus: No subscribers registered for event class org.greenrobot.eventbus.j 07-14 11:39:43.657 16402-16402/com.dhaval.example E/com.dhaval.example.view.a.r$1: Error in getResponse: Attempt to invoke virtual method 'java.lang.String com.dhaval.example.model.entity.Dashboard.b.a()' on a null object reference

1

There are 1 best solutions below

0
On

Definitely sounds like proguard related, but probably not about eventbus, but about your own model.entity.Dashboard class. May be you need to add that model.entity.Dashboard into proguard exceptions:

-keep class model.entity.Dashboard.** { *; }