- 17 Jan 2025
- 2 Minutes à lire
- SombreLumière
- PDF
Shielding rules syntax: definitions
- Mis à jour le 17 Jan 2025
- 2 Minutes à lire
- SombreLumière
- PDF
A file with Shielding Tool rules can be specified via the --rules rules-file command line argument. This file is used to control how the Shielding Tool modifies the Android application, especially with regards to binding and obfuscation. This article explains how the rules file can be used to match classes, fields and methods in order to resolve problems with binding or obfuscation.
Rules syntax
Below are the available commands to be used in a rules file. Although the Shielding Tool only accepts one file as input with the --rules option, you can refer to multiple configuration files in the one sent to the Shielding Tool, as described below. The Shielding Tool parses the rules file(s) and applies the rules as specified.
Definitions
List of operation options | |
Operation Name | Description |
---|---|
include | Include the specified rule file. |
frameworkjar | Path to a.jar file that contains some Android framework code. For more information, see Excluding framework jars from obfuscation. |
verify | Specify file paths to do consistency check on startup. |
skipVerifyPath | Specify file paths to skip paths from consistency check on startup. |
allowScreenshotsForActivity | Exclude an activity from screenshot blocking, where the activity is referenced by its fully qualified class name. For more information, see blockScreenshots. |
List of class_operation options | ||
class_operation (class_op) | opposite of | Description |
---|---|---|
match | - | Select classes or members for some operation. |
bind | untouchable, unbind | Select classes or members to bind or exclude from binding. |
scrambleStrings | keepStrings | Select classes or members in which to scramble constant string values. |
obfuscate | preserve | Select classes or members to obfuscate or exclude from obfuscation. |
removeAnnotation | keepAnnotation | Select classes or members from which to remove annotations. |
removeDebug | keepDebug | Select classes or members from which to remove debug information. |
removeLines | keepLines | Select classes or members from which to remove line numbers. |
removeSourceFile | keepSourceFile | Select classes from which to remove the source file name. |
firstdex | secondarydex | Select classes to include in the first (or secondary) classes.dex. |
List of member_operation options | ||
member_operation (member_op) | opposite of | Description |
---|---|---|
match | - | Select members for some operation. |
bind | untouchable, unbind | Select members to bind or exclude from binding. |
scrambleStrings | keepStrings | Select classes or members in which to scramble constant string values. |
obfuscate | preserve | Select members to obfuscate or exclude from obfuscation. |
removeAnnotation | keepAnnotation | Select classes or members from which to remove annotations. |
removeDebug | keepDebug | Select members from which to remove debug information. |
removeLines | keepLines | Select members from which to remove line numbers. |
class_name
Fully qualified name of Java class. Supports wildcards
member_name
Name of class field(s) and/or method(s). Supports wildcards. There’s a number of additional matchers available:
<any>, <members> will match any/all fields and methods
<fields> will match all fields
<methods> will match all methods
annotation
@<class_name>. A qualified classname, such as @com.example.myannotation. Supports wildcards.
access
public, private, protectedclass_spec
class, enum or interface
extension
extends or implements
flag
static, abstract, final or native
member_type
method or field
value
A double quoted string, any integer or boolean (true or false).
return_type
void, primitive or a fully qualified name of a java class. Supports wildcards.