Is there a way to get ProGuard to return a line number where the crash happened?
I can use retrace
to get to the method, but often for things like NullPointerException
there are too many possibilities and in a large piece of code its extremely hard to determine the underlying cause as you have to check every object and it's life cycle to make sure nothing is wrong. It would really help if ProGuard could narrow this down to a line number for me.
Add this line to your proguard-project.txt file.
# will keep line numbers and file name obfuscation
-renamesourcefileattribute SourceFile
-keepattributes SourceFile,LineNumberTable
https://www.guardsquare.com/en/products/proguard/manual/usage
When you create a new Android project, it tell you about which lines you might want to uncomment:
# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable
# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
So, you should consider having these:
-keepattributes SourceFile,LineNumberTable
-renamesourcefileattribute SourceFile
However, note that for some reason, Firebase Crashlytics team told me this line might interfere with their service:
-renamesourcefileattribute SourceFile
so you might not see good information of crashes stack trace if you use it.
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