org.greenrobot.eventbus.e: Subscriber class com.zero.xbzx.module.question.presenter.SelectPicActivit

日志信息:
org.greenrobot.eventbus.e: Subscriber class com.zero.xbzx.module.question.presenter.SelectPicActivity and its super classes have no public methods with the @Subscribe annotation
at org.greenrobot.eventbus.p.a(SubscriberMethodFinder.java:67)
at org.greenrobot.eventbus.c.a(EventBus.java:140)
at com.zero.xbzx.module.question.presenter.SelectPicActivity.onCreate(SelectPicActivity.java:100)
at android.app.Activity.performCreate(Activity.java:6861)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1119)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2710)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2818)
at android.app.ActivityThread.-wrap12(ActivityThread.java)
at android.app.ActivityThread H . h a n d l e M e s s a g e ( A c t i v i t y T h r e a d . j a v a : 1557 ) a t a n d r o i d . o s . H a n d l e r . d i s p a t c h M e s s a g e ( H a n d l e r . j a v a : 102 ) a t a n d r o i d . o s . L o o p e r . l o o p ( L o o p e r . j a v a : 163 ) a t a n d r o i d . a p p . A c t i v i t y T h r e a d . m a i n ( A c t i v i t y T h r e a d . j a v a : 6401 ) a t j a v a . l a n g . r e f l e c t . M e t h o d . i n v o k e ( N a t i v e M e t h o d ) a t c o m . a n d r o i d . i n t e r n a l . o s . Z y g o t e I n i t H.handleMessage(ActivityThread.java:1557) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:163) at android.app.ActivityThread.main(ActivityThread.java:6401) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit H.handleMessage(ActivityThread.java:1557)atandroid.os.Handler.dispatchMessage(Handler.java:102)atandroid.os.Looper.loop(Looper.java:163)atandroid.app.ActivityThread.main(ActivityThread.java:6401)atjava.lang.reflect.Method.invoke(NativeMethod)atcom.android.internal.os.ZygoteInitMethodAndArgsCaller.run(ZygoteInit.java:901)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:791)

本人问题补充:
debug版本没问题,replace包出现的此错误
解决方案:

      网上方案一: 
            原因:register方法传入的是this,而不是context
            代码修改成:
             EventBus.getDefault().unregister(this);
      网上方案二: 
               原因:混淆出错 eventbus不同版本 包名不一致
               解决:查找对应正确混淆方案
               下面是3.0.0版

-keepattributes *Annotation*
-keepclassmembers class ** {
    @de.greenrobot.event.Subscribe ;
}
-keep enum de.greenrobot.event.ThreadMode { *; }
# Only required if you use AsyncExecutor
-keepclassmembers class * extends de.greenrobot.event.util.ThrowableFailureEvent {
    (Java.lang.Throwable);
}

-keepclassmembers class ** {
    public void onEvent*(**);
}

     网上方案三: 
               原因:EventBus重复注册
               解决:添加判断 如果已经注册不再注册 同样解绑也是
               代码:
       if (!EventBus.getDefault().isRegistered(this)) {
           EventBus.getDefault().register(this);
          }
    //解除注册
        if (EventBus.getDefault().isRegistered(this)){
            EventBus.getDefault().unregister(this);
            }

方案四: 本人错在这里!!!
原因:少了配置混淆
解决:添加关键混淆代码
关键代码:

    -keepclassmembers class ** {
        public void getMessage*(**);   //getMessage是重点 这里要和你接收消息的方法名一样。否则replace包会一直报这个错
                                                        //一般默认方法名为 onEvent 
      }

完整混淆代码

#----------------EventBus----------------
-keepclassmembers class ** {
    public void getMessage*(**);
}
-keepattributes *Annotation*
-keepclassmembers class ** {
    @org.greenrobot.eventbus.Subscribe ;
}
-keep enum org.greenrobot.eventbus.ThreadMode { *; }

# Only required if you use AsyncExecutor
-keepclassmembers class * extends org.greenrobot.eventbus.util.ThrowableFailureEvent {
    (java.lang.Throwable);
}

你可能感兴趣的:(Bug)