混淆后报错的定位
有时,为了方便调试,在进行debug打包安装的时候,通常使用的是release的签名文件。所以这就导致调试出现代码被混淆了(出现a b c等别名),程序崩溃后,定位不到错误的位置和方法。延误开发进度。
1.混淆后,如何显示报错的行号
在proguard-rules.pro 文件中加入
# 设置报错显示行号
-renamesourcefileattribute SourceFile
-keepattributes SourceFile,LineNumberTable
就可以准确的显示具体是哪行出现的问题。
2. 混淆后,如何将混淆的报错信息,还原成具体的信息
上面,我们仅仅定位到了哪行出现的问题。具体是那个的问题,我们只能靠自己的经验进行猜想。那么如何反编译出来报错信息囊?
具体步骤如下:
比如 :下面的空指针的问题
java.lang.NullPointerException: Argument must not be null
at d.b.a.i.l.a(SourceFile:31)
at d.b.a.i.l.a(SourceFile:25)
at d.b.a.k.a(SourceFile:685)
at g.k.a.q.a(SourceFile:309)
at g.f.c.b(SourceFile:52)
at d.f.a.b.a.n.run(SourceFile:43)
at android.os.Hand