gpt4 book ai didi

android - greenrobot事件总线的ProGuard配置

转载 作者:行者123 更新时间:2023-11-30 00:27:24 25 4
gpt4 key购买 nike

我在我的应用程序中使用事件总线,它在 Debug模式下工作正常,但在发布 APK 时不工作。

以下代码用于 ProGuard 配置:

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

All my Subscribe-annotated methods are also public

Logcat 输出:

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

最佳答案

绝对听起来像 proguard 相关,但可能与事件总线无关,而是与您自己的 model.entity.Dashboard 类有关。可能您需要将该 model.entity.Dashboard 添加到混淆器异常中:

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

关于android - greenrobot事件总线的ProGuard配置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45096104/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com