Excluding File Paths

I want to exclude some file paths from ProGuard. Does anyone have any best practices for doing this? Providing examples would be great.

Excluding file paths is simple with ProGuard! (or DexGuard)

Here are some examples:

The following rule keeps the names of all public classes in just the one specified package:

-keep public class com.myapp.ExampleClass.*

The following configuration (recursively) keeps the names of all public classes in the specified package and all of its its subpackages:

-keep public class com.myapp.ExampleClass.**

The following configuration keeps the names of all public/protected classes/fields/methods in the specified package and its subpackages:

-keep public class com.myapp.ExampleClass.** {
  public protected *;
}

Try using the ProGuard Playground to experiment with -keep options. It will show you the output before you build, so you can safe time and effort constructing fine-tuned configurations!

1 Like