Appendix C. ProGuard

 

We need not mention that decent application performance is crucial and difficult to achieve. Though you can spend hours profiling your code, there’s another way to grab some low-hanging performance optimization fruit, and even improve your application’s resistance to being hacked or reverse-engineered along the way. Readers with a strong Java background may already know this useful companion: meet ProGuard.

C.1. Overview

We mentioned ProGuard a few times in chapter 14 when we discussed build management and automation, but didn’t explain in detail what it’s good for or when and how you should use it, so that’s what this section will clarify. In a nutshell, Pro-Guard is a Java class file processor that does two useful things for you:

  • Make your application smaller and faster
  • Make your application difficult to reverse-engineer

It should be mentioned that ProGuard isn’t Android-specific; it was around long before Android. It ships with the SDK though, and can be found in your ANDROID_HOME/tools/proguard folder. The documentation can be found online at http://proguard.sourceforge.net/.

C.2. Enabling ProGuard

C.3. Writing ProGuard rules

C.4. Useful rules and options

C.5. Processing error reports

C.6. Summary