Adding & Decoding ProGuard.

Standard

The ProGuard tool shrinks, optimizes, and obfuscates your code by removing unused code and renaming classes, fields, and methods with semantically obscure names. The result is a smaller sized .apkfile that is more difficult to reverse engineer. Because ProGuard makes your application harder to reverse engineer, it is important that you use it when your application utilizes features that are sensitive to security like when you are Licensing Your Applications.

ProGuard is integrated into the Android build system, so you do not have to invoke it manually. ProGuard runs only when you build your application in release mode.

Enabling ProGuard (Gradle Builds)

  android {
   ...
 
    buildTypes {
        release {
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android.txt'),
            'proguard-rules.pro'
        }
    }
  }

The getDefaultProguardFile('proguard-android.txt') method obtains the default ProGuard settings from the Android SDK tools/proguard/ folder.

Android Studio adds the proguard-rules.pro file at the root of the module, so you can also easily add custom ProGuard rules specific to the current module.

ProGuard outputs the following files after it runs:

  • dump.txt -> Describes the internal structure of all the class files in the .apk file.
  • mapping.txt -> Lists the mapping between the original and obfuscated class, method, and field names. This file is important when you receive a bug report from a release build, because it translates the obfuscated stack trace back to the original class, method, and member names. You need to take a copy of mapping.txt every time to release and publish your app.
  • seeds.txt -> Lists the classes and members that are not obfuscated.
  • usage.txt -> Lists the code that was stripped from the .apk

Decoding Obfuscated Stack Traces

When your obfuscated code outputs a stack trace, the method names are obfuscated, which makes debugging hard, if not impossible. Fortunately, whenever ProGuard runs, it outputs a mapping.txt file, which shows you the original class, method, and field names mapped to their obfuscated names.

The retrace.bat script on Windows or the retrace.sh script on Linux or Mac OS X can convert an obfuscated stack trace to a readable one. It is located in the <sdk_root>/tools/proguard/ directory. The syntax for executing theretrace tool is:

retrace.bat|retrace.sh [-verbose] mapping.txt [<stacktrace_file>]

or you can run proguardgui.bat | sh to run in GUI mode.

ProGuard

How to use proguardgui:-

  • Start ProGuardGui.
  • Select ReTrace from the left side.
  • Browse for the mapping.txt file.01
  • Copy the stack trace error from you Google play account.Screen Shot 2015-11-04 at 12.14.41 PM
  • Click ReTrace!, and that’s it :) Screen Shot 2015-11-04 at 12.14.49 PM

for more information about ProGuard

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s