0

例如,以下错误消息显示从 GameController.java 中的第 435 行抛出 NullPointerException:

java.lang.NullPointerException
at com.fuu.mahjong.game.GameController.boolean showHint(boolean)(GameController.java:435)
at com.fuu.mahjong.game.GameViewActivity.boolean onTouch(android.view.View,android.view.MotionEvent)(GameViewAct
ivity.java:1552)
at android.view.View.dispatchTouchEvent(View.java:7122)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2176)
...

其中 GameController.java 中的第 435 行是

clearCurrentSelections();

clearCurrentSelections() 是 GameController 中的私有方法,错误消息不显示 clearCurrentSelections() 内部的跟踪信息,如果我将 clearCurrentSelections() 更改为 public,则错误消息显示 clearCurrentSelections() 中的哪一行导致 NullPointerException。

使用 ProGuard 后,有什么方法可以在私有方法中显示跟踪信息?

4

1 回答 1

3

ProGuard 的优化步骤可能已经内联了该方法。然后虚拟机在堆栈跟踪中生成更少的行。如果你想避免这种情况,你可以禁用方法内联:

-optimizations !method/inlining/*

在 Dalvik 虚拟机上,方法内联提高了性能。

方法是否是私有的对于优化来说并不重要,除非你的配置明确地保留了公共方法。

于 2013-09-02T16:44:43.510 回答