【问题标题】:RoboGuice @Observes do not work in release buildRoboGuice @Observes 在发布版本中不起作用
【发布时间】:2014-02-19 16:52:18
【问题描述】:

我在我的应用程序中使用 RoboGuice 的 EventManager,如下所示https://code.google.com/p/roboguice/wiki/Events#Creating_your_Own_Events

它在调试版本中完美运行,但事件不会在发布版本中触发 - 可能是由于 ProGuard 混淆。

我试图阻止 ProGuard 处理相关的方法和类,但我想我做错了什么:

这是我尝试过的 ProGuard 配置

-keep class com.myapp.events.*                          # keep all the event classes
-keepclasseswithmembers class * { void on*Event(*); }   # keep methods named on*Event,  eg. onUserClickedEvent

我的主要活动类有如下处理程序:

public void onUserClickedEvent( @Observes UserClicked  event) {
    ...
}

【问题讨论】:

    标签: android proguard roboguice


    【解决方案1】:

    在阅读有关 Proguard 的更多信息后解决...我更改了函数签名并将 Proguard 配置修改为:

    -keep class com.myapp.events.*  
    -keepclasseswithmembers class * { 
       void onEvent*(...); 
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2023-03-27
      • 2022-10-21
      • 2016-09-07
      • 2019-04-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多