Recently, I have to survey ProGuard. We are planning to use ProGuard to protect codes of Android application. As this title, ProGuard can also shrink and optimize APP. So it’s quite useful for Android developers. Android Developers website doesn’t have much information of ProGuard. I suggest everyone go to ProGuard website for more information.

See http://developer.android.com/tools/help/proguard.html 

And this one has more information… http://proguard.sourceforge.net/

Besides ProGuard, DexGuard is another choice.
It seems designed for Android Apps. However, if you wanna use it, you need to buy license.

To enable ProGuard, we can modify a file in Android project, “project.property”.

Find this line:
#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt
Then remove the symbol “#” to enable ProGuard tools.

After finishing property modification, you can export  APK by doing this:
Right-click on your project -> select “Android Tools” -> Export Signed/Unsigned package

This is a way to use ProGuard on Android application by using default configuration in ${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt


After exporting APK, you will see four txt files had been added: dump.txt, mapping.txt, seeds.txt, and usage.txt.

If you want to have custom configuration, you can modify “<your_project_root>/proguard-project.txt”.
The configuration will override the default one.

Reference this website: http://proguard.sourceforge.net/#manual/usage.html
There are many configuration options we could use.

Most important option of all is “-keep”. It helps preserving classes, methods, and fields.

It’s essential to keep some classes on Android, such as classes extend Activity, Service, and so on.

This website also have an example of Android application. The example worth to take a quick look. It has useful configuration suggestions for adopting options. However, it’s not that easy to write a perfect configuration when your app getting complicated. So you might need to spend some time and effort on it. I suggest beginners to read following sections: A complete Android application, Processing native methods, Processing native methods, Processing enumeration classes, and Processing serializable classes.

Let’s take a look at the exported APK file.

The package and classes names had been obfuscated.
So if someone crack your APK, he/she will get nothing!