waynesford
waynesford

Reputation: 1698

Stacktrace is missing methods when proguard obfuscation on

I noticed that on my Crashlytics/Fabric dashboard, for my proguard obfuscated release builds, I would be missing the first (and most important) method + line number of the stack trace. For my debug builds, I would be able to see this method properly.

So concretely, in my onCreateView() I call my updateData() method (where my crash was occurring) but in my obfuscated builds updateData() wasn't showing in the stacktrace, only the onCreateView(). Unobfuscated builds showed the proper stacktrace with both methods.

I'm using proguard-android-optimize.txt because I needed to remove Logs from my release build.

How do I get the proper stack track to show properly?

Upvotes: 1

Views: 1089

Answers (1)

waynesford
waynesford

Reputation: 1698

The stacktrace is inconsistent because the proguard-android-optimize.txt configuration applies ALL optimizations except for the ones specified here (from proguard-android-optimize.txt):

-optimizations !code/simplification/arithmetic,!code/simplification/cast,!field/*,!class/merging/*

So how this reads is anything prepended with the '!' mark is an optimization that's excluded, but all other optimizations are included. Explained here: http://proguard.sourceforge.net/manual/optimizations.html

The reason methods were disappearing from the stack trace is one of the default optimizations is method inlining. So in our proguard-rules.txt file, we simple have to add this line in order to prevent that from happening:

-optimizations !method/inlining/*

Upvotes: 1

Related Questions