Peri Hartman
Peri Hartman

Reputation: 19484

Proguard retrace missing line numbers

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?

Upvotes: 7

Views: 3472

Answers (1)

Peri Hartman
Peri Hartman

Reputation: 19484

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.

Upvotes: 23

Related Questions