Android stacktrace de-obfuscation from ACRA and Jenkins
I use ACRA for bug reports. It's free - as in speech as well as beer - I found (I hope enough) free hosting at couchappy.com, it doesn't require the app to be in the Play Store, it's very configurable and will send reports in the background without bothering the user with a dialog. I also use it to report non-crashes, when something unexpected happens that isn't critical but something I want to investigate. Basically everything at Log.ERROR. I don't use WTFs*.
It's quite easy to set up a local instance as it runs on Apache CouchDB and the setup doc provides URLs for you to replicate the template databases from.
I also use Proguard, I don't want someone decompiling my app and having all the source. Well, they do, but most things have silly names like a, b, and c3. Every time the app is built Proguard runs and will rename things, and they might be given different names each time.
So in ACRA's web interface, Acralyzer, the stacktraces refer to things using a, b and c3, and whilst I can sometimes sort-of-guess it would be very handy to have those turned back into their original names.
When Proguard builds it creates a file 'mapping.txt', and the Android SDK includes a tool called 'retrace' which uses the mapping.txt to un-obfuscate your obfuscated stacktrace.
From a root around it doesn't seem ACRA or Acralyzer can do this retracing automatically. The mapping file is different for every build so it'd need somewhere to store it and identify the build it's for, and retrace is a Java program which can't be run or executed from within couchdb.
So I've knocked up a little bash script that can do this when passed an Acralyzer URL. It expects builds to have been done using Jenkins, Jenkins to archive the mapping.txt files, and Jenkins' build number to be included in the report somewhere. My build puts this in the application's version string anyway (for beta builds) so good old regex gets that out.
The tools curl and jq are used to query couchdb and parse the JSON.
The UX flow isn't great, you have to have a shell open and copy/paste the URL from Acralyzer into the shell, so I'm looking for a nicer way to do this. Couch only serving javascript limits this a bit!
It could be used as a starting point for automatically updating all the stacktraces in the database, I assume couch allows updates via HTTP POSTs so a bit more curl, some looping and maybe cron could automate the entire thing and have the de-obfuscated trace available in Acralyzer's UI.
https://github.com/molexx/acra_jenkins_retrace
*What a Terrible Failure. Google's words, not mine :-)













