Proguard retrace missing line numbers

时间秒杀一切 提交于 2019-12-01 02:55:45

问题


I'm trying to deobfucate a stack trace from my Android app. I used proguard when building the app and running retrace seem to work, more or less.

What isn't working is decoding the line numbers. No line numbers are shown on the output and it lists several choices for each "at".

Here is my proguard-project.txt file:

-keepattributes LineNumberTable
-assumenosideeffects class android.util.Log {
    public static int v(...);
    public static int d(...);
}

This is my stack trace:

uncaught exception
java.lang.NullPointerException
at com.myapp.myapp.dbaccess.ag.a(Unknown Source)
at com.myuapp.myapp.dbaccess.x.a(Unknown Source)
at com.myapp.myapp.dbaccess.x.a(Unknown Source)
at com.myapp.myapp.main.ab.run(Unknown Source)

And here is the output:

uncaught exception
java.lang.NullPointerException
at com.myapp.myapp.dbaccess.ZNodeCache.com.myapp.myapp.dbaccess.ZNode getNodeFromCache(long)(Unknown Source)
                                             com.myapp.myapp.dbaccess.ZRoot getRootFromCache()
                                             com.myapp.myapp.dbaccess.ZNode getNodeFromDb(long,boolean)
                                             com.myapp.myapp.dbaccess.ZNode$Array getChildrenForExport(com.myapp.myapp.dbaccess.ZNode)
                                             ... many more ...
at com.myapp.myapp.dbaccess.XmlImport.com.myapp.myapp.dbaccess.XmlImport$Results importFile(java.lang.String)(Unknown Source)
                                            void _doImport(java.io.InputStream,com.myapp.myapp.dbaccess.XmlImport$Results)
                                            void importFile(java.io.InputStream)
                                            void importNode(org.xmlpull.v1.XmlPullParser,com.myapp.myapp.dbaccess.ZNode)
                                             ... many more ...
at com.myapp.myapp.dbaccess.XmlImport.com.myapp.myapp.dbaccess.XmlImport$Results importFile(java.lang.String)(Unknown Source)
                                            void _doImport(java.io.InputStream,com.myapp.myapp.dbaccess.XmlImport$Results)
                                            void importFile(java.io.InputStream)
                                            void importNode(org.xmlpull.v1.XmlPullParser,com.myapp.myapp.dbaccess.ZNode)
                                             ... many more ...
at com.myapp.myapp.main.MainActivity$3.void run()(Unknown Source)

I must be missing another configuration parameter; any ideas?


回答1:


Turns out the answer is in the Android documentation (believe it or not). I guess I missed it the first time around. You need to specify the source file, like this:

-renamesourcefileattribute SourceFile
-keepattributes SourceFile,LineNumberTable

The renamsesourcefileattribute will cause all source files to have the name SourceFile (or whatever you put). "retrace" doesn't care what the source file name is, but if you leave it out, it decides to ignore the line numbers.

This goes in proguard-project.txt which, if you're using Android Studio, you'll find in "your project".app.



来源:https://stackoverflow.com/questions/21065998/proguard-retrace-missing-line-numbers

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!