ProGuard manual | Reference Card

Reference card

Usage

java -jar proguard.jar options ...

Typically:

java -jar proguard.jar @myconfig.pro

 

Options

@filenameShort for '-includefilename'.
-include filenameRead configuration options from the given file.
-basedirectory directorynameSpecifies the base directory for subsequent relative file names.
-injars class_pathSpecifies the program jars (or wars, ears, zips, or directories).
-outjars class_pathSpecifies the names of the output jars (or wars, ears, zips, or directories).
-libraryjars class_pathSpecifies the library jars (or wars, ears, zips, or directories).
-skipnonpubliclibraryclassesIgnore non-public library classes.
-dontskipnonpubliclibraryclassesDon't ignore non-public library classes (the default).
-dontskipnonpubliclibraryclassmembersDon't ignore package visible library class members.
-keepdirectories [directory_filter]Keep the specified directories in the output jars (or wars, ears, zips, or directories).
-target versionSet the given version number in the processed classes.
-forceprocessingProcess the input, even if the output seems up to date.
-keep [,modifier,...] class_specificationPreserve the specified classes and class members.
-keepclassmembers [,modifier,...] class_specificationPreserve the specified class members, if their classes are preserved as well.
-keepclasseswithmembers [,modifier,...] class_specificationPreserve the specified classes and class members, if all of the specified class members are present.
-keepnames class_specificationPreserve the names of the specified classes and class members (if they aren't removed in the shrinking step).
-keepclassmembernames class_specificationPreserve the names of the specified class members (if they aren't removed in the shrinking step).
-keepclasseswithmembernames class_specificationPreserve the names of the specified classes and class members, if all of the specified class members are present (after the shrinking step).
-printseeds [filename]List classes and class members matched by the various -keep options, to the standard output or to the given file.
-dontshrinkDon't shrink the input class files.
-printusage [filename]List dead code of the input class files, to the standard output or to the given file.
-whyareyoukeeping class_specificationPrint details on why the given classes and class members are being kept in the shrinking step.
-dontoptimizeDon't optimize the input class files.
-optimizations optimization_filterThe optimizations to be enabled and disabled.
-optimizationpasses nThe number of optimization passes to be performed.
-assumenosideeffects class_specificationAssume that the specified methods don't have any side effects, while optimizing.
-allowaccessmodificationAllow the access modifiers of classes and class members to be modified, while optimizing.
-mergeinterfacesaggressivelyAllow any interfaces to be merged, while optimizing.
-dontobfuscateDon't obfuscate the input class files.
-printmapping [filename]Print the mapping from old names to new names for classes and class members that have been renamed, to the standard output or to the given file.
-applymapping filenameReuse the given mapping, for incremental obfuscation.
-obfuscationdictionary filenameUse the words in the given text file as obfuscated field names and method names.
-classobfuscationdictionary filenameUse the words in the given text file as obfuscated class names.
-packageobfuscationdictionary filenameUse the words in the given text file as obfuscated package names.
-overloadaggressivelyApply aggressive overloading while obfuscating.
-useuniqueclassmembernamesEnsure uniform obfuscated class member names for subsequent incremental obfuscation.
-dontusemixedcaseclassnamesDon't generate mixed-case class names while obfuscating.
-keeppackagenames [package_filter]Keep the specified package names from being obfuscated.
-flattenpackagehierarchy [package_name]Repackage all packages that are renamed into the single given parent package.
-repackageclasses [package_name]Repackage all class files that are renamed into the single given package.
-keepattributes [attribute_filter]Preserve the given optional attributes; typically Exceptions, InnerClasses, Signature, Deprecated, SourceFile, SourceDir, LineNumberTable, LocalVariableTable, LocalVariableTypeTable, Synthetic, EnclosingMethod, and *Annotation*.
-keepparameternamesKeep the parameter names and types of methods that are kept.
-renamesourcefileattribute [string]Put the given constant string in the SourceFile attributes.
-adaptclassstrings [class_filter]Adapt string constants in the specified classes, based on the obfuscated names of any corresponding classes.
-adaptresourcefilenames [file_filter]Rename the specified resource files, based on the obfuscated names of the corresponding class files.
-adaptresourcefilecontents [file_filter]Update the contents of the specified resource files, based on the obfuscated names of the processed classes.
-dontpreverifyDon't preverify the processed class files.
-microeditionTarget the processed class files at Java Micro Edition.
-verboseWrite out some more information during processing.
-dontnote [class_filter]Don't print notes about potential mistakes or omissions in the configuration.
-dontwarn [class_filter]Don't warn about unresolved references at all.
-ignorewarningsPrint warnings about unresolved references, but continue processing anyhow.
-printconfiguration [filename]Write out the entire configuration in traditional ProGuard style, to the standard output or to the given file.
-dump [filename]Write out the internal structure of the processed class files, to the standard output or to the given file.

Notes:

  • class_path is a list of jars, wars, ears, zips, and directories, with optional filters, separated by path separators.
  • filename can contain Java system properties delimited by '<' and '>'.
  • If filename contains special characters, the entire name should be quoted with single or double quotes.

 

Overview of keep options

KeepFrom being removed or renamedFrom being renamed
Classes and class members-keep-keepnames
Class members only-keepclassmembers-keepclassmembernames
Classes and class members, if class members present-keepclasseswithmembers-keepclasseswithmembernames

 

Keep option modifiers

includedescriptorclassesAlso keep any classes in the descriptors of specified fields and methods.
allowshrinkingAllow the specified entry points to be removed in the shrinking step.
allowoptimizationAllow the specified entry points to be modified in the optimization step.
allowobfuscationAllow the specified entry points to be renamed in the obfuscation step.

 

Class specifications


[@annotationtype] [[!]public|final|abstract ...] [!]interface|class classname
    [extends|implements [@annotationtype] classname]
[{
    [@annotationtype] [[!]public|private|protected|static|volatile|transient ...] <fields> |
                                                                      (fieldtype fieldname);
    [@annotationtype] [[!]public|private|protected|static|synchronized|native|abstract|strictfp ...] <methods> |
                                                                                           <init>(argumenttype,...) |
                                                                                           classname(argumenttype,...) |
                                                                                           (returntype methodname(argumenttype,...));
    [@annotationtype] [[!]public|private|protected|static ... ] *;
    ...
}]

Notes:

  • Class names must always be fully qualified, i.e. including their package names.
  • Types in classname, annotationtype, returntype, and argumenttype can contain wildcards: '?' for a single character, '*' for any number of characters (but not the package separator), '**' for any number of (any) characters, '%' for any primitive type, '***' for any type, and '...' for any number of arguments.
  • fieldname and methodname can contain wildcards as well: '?' for a single character and '*' for any number of characters.