Configure PreEmptive Protection™ DashO™ Removal from four pages in the DashO user interface: Removal - Options, Removal - Exclude, Removal - Classes, and Method Call Removal. Use them to remove unused code and unneeded attributes, keep specific items, remove specific classes, and remove calls to specific methods.
To learn how Removal works, see Removal and Method Call Removal.
Prerequisites
- A DashO project in Standard Mode. The Removal pages are only available in Standard Mode.
Configure Removal Options
- In the navigation tree, select Removal.
- In Unused Classes, choose how DashO removes unused classes.
- In Unused Members, choose how DashO removes unused methods and fields.
- Under Debug Information, select each item to remove.
- Under Attributes, select each item to remove.
- Save your project and build it to apply the changes.
Removal Options Settings
| Setting | Description | Project file element |
| Unused Classes | Removes all unused classes (Remove), only those without a public or protected modifier (Remove if not public), or none (Do not remove). | <removal> |
| Unused Members | Removes all unused methods and fields (Remove), only non-public ones (Remove if not public), or none (Do not remove). | <removal> |
| Debug Information | Removes the selected debugging information the compiler inserts. | <debug> |
| Attributes | Removes the selected additional attributes. | <attributes> |
Remove Deprecation Metadata
When you select Deprecated under Attributes, DashO removes both the JVM Deprecated attribute and the java.lang.Deprecated annotation. Other annotations stay unchanged.
To keep the annotation, set preserveDeprecatedAnnotation="true" on the <attributes> element in your project file. The default is false.
<attributes
types="Deprecated"
preserveDeprecatedAnnotation="true"/>Exclude Items from Removal
Use the Removal - Exclude page to keep individual methods, fields, classes, or entire packages from being removed. The page uses the DashO rules editor. For details on creating, editing, and previewing rules, see Graphical Rules Editor.
- In the navigation tree, go to Removal > Exclude.
- Create rules for the items you want DashO to keep. For more information, see Graphical Rules Editor.
- Save your project and build it to apply the changes.
Remove Specific Classes
Use the Removal - Classes page to remove classes regardless of whether your code uses them, such as unit tests or samples.
- In the navigation tree, go to Removal > Classes.
- Create rules for the classes or packages to remove. For more information, see Graphical Rules Editor.
- Save your project and build it to apply the changes.
Configure Method Call Removal
Use the Method Call Removal page to remove calls to specific methods. See Method Call Removal for how it works and how it changes your program's behavior.
- In the navigation tree, go to Removal > Method Calls.
- Add a rule for each method whose calls you want to remove. Enter the class name, method name, and signature.
- Save your project and build it to apply the changes.
Examples and Use Cases
| Goal | Page | What to do |
| Remove unused code from an application | Removal - Options | Set Unused Classes and Unused Members to Remove. |
| Keep readable stack traces | Removal - Options | Clear Line Number Table and Source File under Debug Information. |
| Keep a class your code loads through reflection | Removal - Exclude | Add an exclude rule for the class. |
| Strip unit tests from the output | Removal - Classes | Add a rule for the test package. |
| Remove logging calls | Method Call Removal | Add a rule for each logging method. |
Limitations and Troubleshooting
| Issue | Resolution |
| The Removal pages aren't visible. | They're only available in Standard Mode. In Android Mode, R8 handles removal. |
| An excluded class is still removed. | Remove the matching rule from Removal Classes. Those rules override exclusions. |
| A Method Call Removal rule doesn't match. | Regular expressions aren't supported. Enter the exact class name, method name, and signature. |
Code that reads @Deprecated stops working. |
Set preserveDeprecatedAnnotation="true". See Remove Deprecation Metadata. |