Skip to content

Android Proguard with useful stack-traces

As I said in my previous post about using Proguard with Android apps, the only drawback is that the stack-traces (following an application crash) become illegible. But that is not entirely true because Proguard allows you to shrink while maintaining useful stack-traces. After this finding, there isn’t really any drawback to using Proguard anymore!

The updated Proguard config I use with Android is:

-keep public class * extends
-keep public class * extends android.view.View { public (...); }
-optimizationpasses 2
-keepattributes SourceFile,LineNumberTable
-printmapping map.txt

The line “-keepattributes SourceFile,LineNumberTable” instructs Proguard to not strip the file name and line number information, which results in readable stack-traces. Keeping this information makes the shrinking a bit less efficient, but it still reduced my test app from 56KB to 40KB which is impressive.

Post a Comment

Your email is never published nor shared. Required fields are marked *