ProGuard is a utility for code reduction, optimization, and obfuscation. At the exit, you get a smaller * .apk, which is much more difficult to reengineer. On
developer.android.com it is written that ProGuard is embedded in the Android application build system. However, I noticed that this utility appeared in my folder with the SDK only after upgrading to r9.
ProGuard runs only when you run the build in “release” mode. For those who don’t know how to do it (in Eclipse): right-click the context menu of the project, then
Export -> Android -> Export Android Application . The config file appears automatically when creating a project, in its root, under the name
proguard.cfg . If you didn’t see it, check for the presence of the utility in the folder with your SDK
Next, to enable the obfuscator itself before building, add a line like
proguard.config = / path / proguard.cfg , where path is the path to the file, to the
/root_of_your_project/default.properties file. Thus you can drag one config for a heap of projects.
So, after the “release” of the ProGuard build, we’ve got a bit of a waste in one of the following folders:
- / root_of_your_project / proguard — when using Eclipse
- / root_of_your_project / bin / proguard - when using Ant
Files are created:
- dump.txt - describes the insides of all class files in your * .apk
- mapping.txt - represents the mapping between source and obfuscated classes, class fields, methods.
- seeds.txt - list of non-fuscated classes
- usage.txt - code pulled from * .apk
Also on developer.android.com warn that when processing code with ProGuard, there may be complications in the form of a
ClassNotFoundException . To avoid this, you can add a line to the config:
-keep public class <MyClass>
More information about configuring the config can be found
here . Actually, there you can find a
couple of samples .
')
In addition, in the folder / path_to_your_SDK / tools / proguard / bin there is a script called
retrace.bat (for Linux / Mac OS X,
retrace.sh ). It allows you to convert obfuscated into readable, using the above
mapping.txt .
Usage syntax:
retrace.bat|retrace.sh [-verbose] mapping.txt [<stacktrace_file>]
For example:
retrace.bat -verbose mapping.txt obfuscated_trace.txt
Also, the script accepts standard manual text input, in case you are too lazy to write the path to <stacktrace_file>.
If at the first launch in “release” mode with ProGuard (with default settings) an error with code 1 crashes, then most likely there are gaps in the path to your SDK - delete them and everything will work.
Enjoy your obfuscation!