@Retention(CLASS) @Target({TYPE})

public @interface Hardening

App hardening build hints, checked by the compiler.

Place this on your application’s main class – the class named by codename1.mainName. An attribute you do not set is not written at all, so the build server’s own default applies. The default clause below each attribute names a constant that says nothing – see HintUnset – and this package deliberately does not record what the server would do instead, because that is the server’s to change.

Methods

public abstract Toggle allowUnhardenedLocalBuild() default Toggle.DEFAULTPermits a local or source build to run with hardening requested but not applied.
public abstract HardenControlFlow controlFlow() default HardenControlFlow.DEFAULTOverrides control-flow obfuscation independently of harden.level.
public abstract String keep() default ""Keep rules in ProGuard syntax, one per line, for classes that are resolved by name at runtime and so can’t be found by the automatic analysis.
public abstract HardenLevel level() default HardenLevel.DEFAULTMaster switch for app hardening: off, standard, aggressive or paranoid.
public abstract Toggle rename() default Toggle.DEFAULTOverrides symbol renaming independently of harden.level.
public abstract HardenStrings strings() default HardenStrings.DEFAULTOverrides string obfuscation independently of harden.level: off, constants or all.

Method details

allowUnhardenedLocalBuild

public abstract Toggle allowUnhardenedLocalBuild() default Toggle.DEFAULT
Permits a local or source build to run with hardening requested but not applied. Without it such a build is refused, so a hardened app is never shipped from a target that can’t actually harden it.

controlFlow

public abstract HardenControlFlow controlFlow() default HardenControlFlow.DEFAULT
Overrides control-flow obfuscation independently of harden.level.

keep

public abstract String keep() default ""
Keep rules in ProGuard syntax, one per line, for classes that are resolved by name at runtime and so can’t be found by the automatic analysis. Same syntax as android.proguardKeep, so existing rules port directly. Rules are separated by newlines only, because a semicolon is legal inside a rule body such as { *; }.

level

public abstract HardenLevel level() default HardenLevel.DEFAULT
Master switch for app hardening: off, standard, aggressive or paranoid. An unrecognized value fails the build rather than being treated as off.

rename

public abstract Toggle rename() default Toggle.DEFAULT
Overrides symbol renaming independently of harden.level.

strings

public abstract HardenStrings strings() default HardenStrings.DEFAULT
Overrides string obfuscation independently of harden.level: off, constants or all.