I'm having an issue where my stack traces from the developer console don't match up with the code. The line numbers are off notably and methods that had to be in the trace won't exist in the trace on the console. For example (simplified console trace):
at getBitmapSize
at getBitmapBytes
at onActivityResult
However in code it MUST take this path:
onActivitResult -> handleSaveImage -> getBitmapBytes -> getBitmapSize
This segment of code has not changed in years so it's not a matter of using a bad mapping.txt. Somehow applying proguard is removing structure in the app. Is that possible? Would it not map back out?
I never saw missing methods in stack traces before turning proguard on.
Also is there anything I should know about getting line numbers to match up?
I've set:
-keepattributes SourceFile,LineNumberTable
which almost works. They just never line up properly.
I set up a test that would throw an NPE at a predictable inline spot.
(Optimized) The logcat error had proper line numbers and a method that was separated only for clarity was clearly in-lined. With the proper line numbers everything was a lot more obvious.
(Un-optimized) Got the same stack trace except for the additional method was in the trace. Once again the line numbers were correct.
I don't understand why the developer console traces had the wrong line numbers, but that was the reason it was so hard to follow. Not only were they off in one file, but they were off in all files, so it was just a confusing mess, especially anywhere you had multiple exception handling like i/o.
I submitted the un-optimized app to the Play store and stack traces line up now. I'd recommend not using the optimizations in a complicated app when you'll depend on Play stack traces.
When you have Proguard optimization enabled, it may inline small methods. This would explain why there would appear to be missing steps in your stacktrace. Try disabling optimization in your Proguard config. See Android Proguard does not inline for guidance on how optimization is configured for Android.
If you're using the Gradle build system, there will be a line in your build.gradle
containing something like this:
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.txt'
To experiment with disabling optimization, change that to
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With