【问题标题】:EventBus onEvent() not found after deployment部署后未找到 EventBus onEvent()
【发布时间】:2015-09-11 18:01:58
【问题描述】:

我正在使用 Eclipse Luna SR1 进行 Java 开发。该应用程序已在物理设备上成功测试。然而,在我部署它之后,我收到了 ClassNotFoundException 声称我的活动中没有 onEvent() 方法......但它就在那里。

有人遇到过同样的问题吗?

【问题讨论】:

  • 部署下是什么意思?生产版本?
  • 是的,我生成了一个 APK 并将其作为测试版发送到 GooglePlay。
  • 你用过proguard吗?
  • Yes'ir...我确实做到了(虽然不太喜欢它):)

标签: java classnotfoundexception event-bus


【解决方案1】:

使用 proguard 时需要将其添加到 proguard.config 中

## GreenRobot EventBus specific rules ##
# https://github.com/greenrobot/EventBus/blob/master/HOWTO.md#proguard-configuration

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

# Only required if you use AsyncExecutor
-keepclassmembers class * extends de.greenrobot.event.util.ThrowableFailureEvent {
    public <init>(java.lang.Throwable);
}

# Don't warn for missing support classes
-dontwarn de.greenrobot.event.util.*$Support
-dontwarn de.greenrobot.event.util.*$SupportManagerFragment

官方文档https://github.com/greenrobot/EventBus/blob/master/HOWTO.md#proguard-configuration

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-01-09
    • 2012-06-16
    • 2023-03-15
    • 2022-10-07
    • 2017-06-23
    相关资源
    最近更新 更多