HockeyApp and ProGuard

ProGuard is a tool to optimize and obfuscate the code of your Android apps. It removes unused code helping you to stay below the 65K reference limit. It also renames classes, fields, and methods with semantically obscure names. This of course means, that in order for you to read the stack traces we first have to perform a deobfuscation step similar to the symbolication steps on other platforms. This article describes how to configure ProGuard together with HockeyApp and how to symbolicate stack traces from such apps.

Requirements

This article is aimed at developers using our latest HockeySDK for Android in combination with Android Studio.

Enable ProGuard

To enable ProGuard, follow the official instructions first. Make sure that you don't run ProGuard in debug builds.

Configure ProGuard

Starting with our 3.7.0 release, the Android SDK ships with the required ProGuard configuration out of the box, so typically you won't have to do anything.

However, if you provide a custom user interface fragment for the update distribution module, e.g. by overriding UpdateManagerListener.getUpdateFragmentClass() you will have to add an exception to your ProGuard configuration, since this class is instantiated via reflection. Follow these steps:

  1. Open your app module's ProGuard configuration (proguard-rules.pro in your app's module in Android Studio)
  2. Add the following lines at the end of your existing configuration, using the full class name of your custom update fragment:
-keepclassmembers class your.custom.UpdateFragment { 
  *;
}

Deobfuscating/Symbolicating Stack Traces

During the build process, ProGuard generates a file with the mapping between the original and obfuscated class, method, and field names. You can upload this file to HockeyApp to get crash logs symbolicated automatically. The setup is quite simple:

  1. Go to your app's page on HockeyApp.
  2. Select the version for which you want to activate symbolication.
  3. Upload the file proguard/mapping.txt from your app module's build directory.

Please note that HockeyApp can not check if you have uploaded the right file. We therefore recommend to upload the file directly after you have created the .apk file or push it to your code repository if you want to upload it later.

You can also upload the file via our API: Upload New Apps or API: Upload New Versions. Just set the parameter "dsym" to your mapping.txt file.

Keeping Line Numbers

ProGuard not only obfuscates the class and method names, but also removes the filename and line numbers from the stack trace. This makes finding errors complicated, especially in methods with lots of lines. You can keep the line numbers by adding the following code to your proguard.cfg:

-renamesourcefileattribute SourceFile
-keepattributes SourceFile,LineNumberTable

This will replace the filename in the stack trace with "SourceFile", but keep the line numbers.