Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 638
Peri Hartman Avatar asked Jan 11 '14 18:01

Peri Hartman


People also ask

How do I read a ProGuard map?

It should be located at build/outputs/proguard/release/mapping. txt in your application module's directory. In the latest version of ProGuard and Android Studio, the file is located at build/outputs/mapping/release/mapping. txt .

What is a ReTrace mapping file for Android?

A mapping file contains the original names and the obfuscated names of classes, fields, and methods. ProGuard can write out such a file while obfuscating an application or a library, with the option -printmapping . ReTrace requires the mapping file to restore obfuscated stack traces to more readable versions.


1 Answers

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.

like image 123
Peri Hartman Avatar answered Dec 31 '22 00:12

Peri Hartman