Using ProGuard with Android

ProGuard obfuscates and shrinks .apk files, providing some added protection for your app, but you may encounter some problems using it up right now, at least with ADT 9 preview 3.By default ADT creates a proguard.cfg file with every new project, so i…

ProGuard obfuscates and shrinks .apk files, providing some added protection for your app, but you may encounter some problems using it right now, at least with ADT 9 preview 3.

By default ADT creates a proguard.cfg file with every new project, so if you have an existing project just copy it over from a new dummy project. The next step is to enable ProGuard, you do this by adding the following to your default.properties file:

proguard.config=proguard.cfg

(assuming proguard.cfg is the ProGuard configuration file created for you, or copied from a new project, into the project root folder.)

When you export an APK release ADT will now run ProGuard on the code, however if like me you have any spaces in your project folder path it will fail. So for now please avoid any spaces in both your project folder path, and the Android SDK path. I believe Google are looking to resolve this in an update.

If you are using something like remote-stack-trace to receive crash reports you will need to follow the instructions on the Android site for automatically mapping the obfuscated code to make it human readable again.

One thought on “Using ProGuard with Android”

  1. 6 comments restored from database:

    Juan Delgado said on : 10/01/11 @ 09:43

    Amazed that this kind of careless mistakes keep happening to big companies. Something like this happened years ago to Adobe with the IDE, specially if you had a non-English OS.

    Juan

    Richard Leggett® said on : 10/01/11 @ 10:20

    Thanks goodness for StackOverflow. 😉

    vector said on : 30/01/11 @ 13:21

    good article. thanks for sharing it

    Noob said on : 07/02/11 @ 21:44

    It says in the default.properties file “DO NOT MODIFY THIS FILE…” Am I missing something?

    Also, the build.properties file (which is mentioned in the default.properties file) can nowhere be found.

    Richard Leggett® said on : 07/02/11 @ 21:51

    Yeah I believe it’s safe to do, I remember reading a comment somewhere from an SDK author about this, but you could consider adding the line to your own build.properties instead.

Comments are closed.