在Android Studio做混淆时,出现如下错误:

java.lang.RuntimeException: Unable to start activity ComponentInfo{com.csair.pda/com.csair.pda.login2main.MainActivity}: de.greenrobot.event.EventBusException: Subscriber class com.csair.pda.login2main.MainActivity has no public methods called onEvent


Caused by: de.greenrobot.event.EventBusException: Subscriber class com.csair.pda.login2main.MainActivity has no public methods called onEvent


Caused by: de.greenrobot.event.EventBusException: Subscriber class ... has no public methods called_sed

MainActivity.java的第266行代码是异常对象生成的地方:

Caused by: de.greenrobot.event.EventBusException: Subscriber class ... has no public methods called_java_02


解决办法:

在混淆配置中加入如下配置:

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

这个配置可以保证类中的onEvent开头的public方法不会被混淆。

谢谢阅读。