Jacky
Jacky

Reputation: 58

exception trace does not show line number for private method after use ProGuard

for example, the followng error message shows that NullPointerException thrown from line number 435 in GameController.java:

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)
...

where line number 435 in GameController.java is

clearCurrentSelections();

clearCurrentSelections() is a private method in GameController, the error message does not show trace information inside clearCurrentSelections(), if I change clearCurrentSelections() to public, then the error message shows that which line in clearCurrentSelections() cause the NullPointerException.

Is there any way to show the trace information inside a private method after use ProGuard?

Upvotes: 0

Views: 615

Answers (1)

Eric Lafortune
Eric Lafortune

Reputation: 45676

ProGuard's optimization step has probably inlined the method. The virtual machine then produces fewer lines in the stack trace. If you want to avoid this, you can disable method inlining:

-optimizations !method/inlining/*

On the Dalvik virtual machine, method inlining improves the performance though.

Whether the method is private or not shouldn't matter for the optimization, unless your configuration explicitly keeps public methods.

Upvotes: 3

Related Questions