Here are few lines from proguard-rules.pro
-keepattributes *Annotation*
-keepattributes Signature
-keepattributes InnerClasses,EnclosingMethod
-renamesourcefileattribute SourceFile
-keepattributes SourceFile,LineNumberTable
-keep public class * extends java.lang.Exception
-dontwarn org.apache.http.**
Logcat output (error line number is listed as 1133, while my source file is 100 lines longer)
09-04 16:11:46.698 3827-5280/com.XX.main E/AndroidRuntime: FATAL EXCEPTION: IntentService[ActivityRecognizedTracker]
Process: com.XX.main, PID: 3827
java.lang.NullPointerException: Attempt to read from field 'double com.XX.trips.Trip.a' on a null object reference
at com.XX.ActivityRecognizedTracker.onHandleIntent(SourceFile:1133)
I am preserving the line numbers and source file attributes, but stack trace is still obfuscated. What am I doing wrong?
Obfuscating package names myapplication. MyMain is the main application class that is kept by the configuration. All other class names can be obfuscated. Note that not all levels of obfuscation of package names may be acceptable for all code.
-keep Specifies classes and class members (fields and methods) to be preserved as entry points to your code. For example, in order to keep an application, you can specify the main class along with its main method. In order to process a library, you should specify all publicly accessible elements.
ProGuard can't obfuscate strings. xml. You can use other software to obfuscate your file like DexGuard.
AFAIK it's not possible to obfuscate the code and have original stacktraces. So if you want to see original method and class names in the stacktrace, you have to add -dontobfuscate
rule.
But you don't really need the original stacktrace.
You are using -keepattributes SourceFile,LineNumberTable
and that enables you to unambiguously retrace the stacktrace. Just don't forget to keep the generated mapping.txt
file.
Moreover if you remove -renamesourcefileattribute SourceFile
you'll see the original file names in the parentheses. The line number is already there, so you should be able to figure out without retracing where the exception actually happened.
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