Proguard不会在stacktrace中保留行号和方法名 [英] Proguard doesnt preserve the line numbers and method names in stacktrace

查看:249
本文介绍了Proguard不会在stacktrace中保留行号和方法名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是来自proguard-rules.pro的几行

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输出(错误行号列为1133,而我的源文件长100行)

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?

推荐答案

AFAIK,无法混淆代码并具有原始堆栈跟踪.因此,如果要在堆栈跟踪中查看原始方法和类名,则必须添加-dontobfuscate规则.

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.

但是您实际上并不需要原始的堆栈跟踪.

您正在使用-keepattributes SourceFile,LineNumberTable,它使您能够明确地追溯堆栈跟踪.只是不要忘记保留生成的mapping.txt文件.

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.

此外,如果删除-renamesourcefileattribute SourceFile,您会在括号中看到原始文件名.行号已经存在,因此您应该能够找出而不必追溯异常实际发生的位置.

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.

这篇关于Proguard不会在stacktrace中保留行号和方法名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆