Usage

Windows:
Linux/Mac:

Typically:

Windows:
Linux/Mac:

Options

@filename
-include filename
-basedirectory directoryname
-injars class_path
-outjars class_path
-libraryjars class_path
-skipnonpubliclibraryclasses
-dontskipnonpubliclibraryclasses
-dontskipnonpubliclibraryclassmembers
-keepdirectories [directory_filter]
-target version
-forceprocessing
-keep [,modifier,...] class_specification
-keepclassmembers [,modifier,...] class_specification
-keepclasseswithmembers [,modifier,...] class_specification
-keepnames class_specification
-keepclassmembernames class_specification
-keepclasseswithmembernames class_specification
-if class_specification
-printseeds [filename]
-dontshrink
-printusage [filename]
-whyareyoukeeping class_specification
-dontoptimize
-optimizations optimization_filter
-optimizationpasses n
-assumenosideeffects class_specification
-assumenoexternalsideeffects class_specification
-assumenoescapingparameters class_specification
-assumenoexternalreturnvalues class_specification
-assumevalues class_specification
-allowaccessmodification
-mergeinterfacesaggressively
-dontobfuscate
-printmapping [filename]
-applymapping filename
-obfuscationdictionary filename
-classobfuscationdictionary filename
-packageobfuscationdictionary filename
-overloadaggressively
-useuniqueclassmembernames
-dontusemixedcaseclassnames
-keeppackagenames [package_filter]
-flattenpackagehierarchy [package_name]
-repackageclasses [package_name]
-keepattributes [attribute_filter]
-keepparameternames
-renamesourcefileattribute [string]
-adaptclassstrings [class_filter]
-adaptresourcefilenames [file_filter]
-adaptresourcefilecontents [file_filter]
-dontpreverify
-microedition
-android
-verbose
-dontnote [class_filter]
-dontwarn [class_filter]
-ignorewarnings
-printconfiguration [filename]
-dump [filename]
-addconfigurationdebugging

Notes:

  • class_path is a list of jars, apks, aabs, aars, wars, ears, jmods, 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 {: #keepoverview}

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 {: #keepoptionmodifiers}

includedescriptorclasses
includecode
allowshrinking
allowoptimization
allowobfuscation

Class Specifications {: #classspecification}

[@annotationtype] [[!]public|final|abstract|@ ...] [!]interface|class|enum classname
    [extends|implements [@annotationtype] classname]
[{
    [@annotationtype]
    [[!]public|private|protected|static|volatile|transient ...]
    <fields> | (fieldtype fieldname [= values]);

    [@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, ‘...’ for any number of arguments, and ‘<n>’ for the n'th matched wildcard in the same option.
  • fieldname and methodname can contain wildcards as well: ‘?’ for a single character and ‘*’ for any number of characters.