绿色机器人事件总线的ProGuard配置



我正在我的应用程序中使用eventbus,它在调试模式下工作正常,但在发布APK上不起作用。

以下代码用于专业卫士配置:

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

我所有的订阅注释方法也是公开的

日志输出:

无法调度事件:类 com.dhaval.example.model.entity.response.DashboardUnreadStoryResponse 到订阅类类 com.dhaval.example.view.activity.MainActivity java.lang.NullPointerException: Try to invoke virtual method 'java.lang.String com.dhaval.example.model.entity.Dashboard.b.a()' on 空对象引用 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) 在rx.c.a.a_(源文件:134) at rx.internal.operator.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-1411:39:43.640 16402-16402/com.dhaval.example D/EventBus:无订阅者 注册活动类 org.greenrobot.eventbus.j 07-14 11:39:43.657 16402-16402/com.dhaval.example E/com.dhaval.example.view.a.r$1:getResponse 中的错误:尝试 调用虚拟方法 'java.lang.String com.dhaval.example.model.entity.Dashboard.b.a()' on a null object 参考

听起来肯定与 proguard 相关,但可能不是关于 eventbus,而是关于您自己的 model.entity.Dashboard 类。 可能需要将该 model.entity.Dashboard 添加到 proguard 例外中:

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

最新更新