Monday, December 16, 2013

How to obfuscate an Android APK file using ProGuard in the Eclipse ADT

The classes in the Android APK can be obfuscated using the ProGuard tool in the Android Development Toolkit (ADT) in Eclipse. The following shows how to enable to source code obfuscation.
  1. In Eclipse, open up an Android project e.g. androidgames.
  2. Open up the file project.properties in the Eclipse text editor.


  3. Uncomment the following line by removing the # symbol in the first column.

    #proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt
  4. Optional. If there are any classes that you do not want to obfuscate, then the class must be added to the proguard-project.txt file, e.g. com.dom925.trains.manila.SvgInterface, as shown below.
# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
#   public *;
#}
-keepclassmembers class com.dom925.trains.manila.SvgInterface {
public *;
}

An example of a decompiled obfuscated Android APK is shown below.

No comments: