Shield for Android
ByteHide Shield for Android protects your Java and Kotlin applications against reverse engineering, code analysis, and tampering. It integrates directly into your Gradle build pipeline, applying compile-time obfuscation and runtime protections to produce hardened APKs and AABs.
Shield for Android protects your Java and Kotlin applications against reverse engineering, code analysis, and tampering. It integrates directly into your Gradle build pipeline and applies protections at compile time, producing a hardened APK or AAB with no changes to your source code.
How It Works
Shield operates as a Gradle plugin that transforms your compiled bytecode during the build process. When you run a release build, Shield intercepts the compiled .class files before packaging and applies the configured protections. Only your project's own source code is obfuscated by default; dependency JARs are passed through untouched.
The process is transparent to your development workflow: apply the plugin, choose a preset or configure protections individually, and Shield handles the rest automatically on every build.
What It Protects Against
Shield addresses the core vulnerabilities of Android applications:
- Reverse engineering: Decompilers like JADX and JD-GUI produce readable source from unprotected APKs. Shield makes decompiled output incomprehensible through name obfuscation, control flow transformation, and string encryption.
- String extraction: Attackers search for API keys, URLs, and credentials in plaintext strings embedded in the bytecode. String encryption renders these unreadable at rest.
- Static analysis: Automated tools analyze code structure to find vulnerabilities. Control flow obfuscation and constant mutation break the patterns these tools rely on.
- Dynamic analysis: Debuggers and instrumentation frameworks like Frida attach to running applications. Anti-debug detection identifies and responds to these tools at runtime.
- Tampering: Attackers modify APKs to bypass license checks, remove ads, or inject malicious code. Anti-tamper verification detects modifications to the application package.
Available Protections
Shield provides 9 protections organized in three categories. 7 are available via Gradle DSL; 2 additional protections (Reference Proxy and Resource Protection) are available exclusively through the CLI/JSON config.
Code Obfuscation
| Protection | CLI/JSON Name | DSL Property | What It Does |
|---|---|---|---|
| Name Obfuscation | NameObfuscation | nameObfuscation | Renames classes, methods, and fields to meaningless identifiers |
| Control Flow Obfuscation | ControlFlowMatrix | controlFlowObfuscation | Inserts opaque predicates and restructures method logic |
| Reference Proxy | ReferenceProxy | CLI/JSON only | Redirects method and field calls through generated proxy methods |
Data Protection
| Protection | CLI/JSON Name | DSL Property | What It Does |
|---|---|---|---|
| String Encryption | StringEncryption | stringEncryption | Encrypts string literals and decrypts them at runtime |
| Constant Mutation | ConstantMutation | constantMutation | Transforms numeric constants into equivalent expressions |
| Resource Protection | ResourceProtection | CLI/JSON only | Encrypts embedded resources within the JAR/APK |
Runtime Protections
| Protection | CLI/JSON Name | DSL Property | What It Does |
|---|---|---|---|
| Anti-Debug | AntiDebug | antiDebug | Detects debuggers, Frida, Xposed, and instrumentation tools |
| Anti-Tamper | AntiTamper | antiTamper | Verifies application integrity and detects package modifications |
| Debug Removal | DebugInfoRemoval | debugRemoval | Strips debug metadata from compiled bytecode |
Presets
Presets let you configure all protections with a single line:
shield {
projectToken = "your-project-token"
preset("mobile")
}shield {
projectToken = "your-project-token"
preset("mobile")
}mobile— Best for most Android apps. Enables string encryption, constant mutation, debug removal, and anti-debug.server— Best for backend JVM apps. Enables string encryption, constant mutation, debug removal, and name obfuscation.aggressive— Maximum security. Enables all 7 DSL protections plusrepackageClasses.
You can override individual protections after applying a preset.
Quick Example
Add Shield to an existing Android project in three steps:
1. Add the plugin
// app/build.gradle.kts
plugins {
id("com.android.application")
id("org.jetbrains.kotlin.android")
id("com.bytehide.shield") version "1.1.5"
}// app/build.gradle.kts
plugins {
id("com.android.application")
id("org.jetbrains.kotlin.android")
id("com.bytehide.shield") version "1.1.5"
}2. Configure protections
shield {
projectToken = "your-project-token"
preset("mobile")
}shield {
projectToken = "your-project-token"
preset("mobile")
}3. Build
./gradlew assembleRelease./gradlew assembleReleaseShield processes the bytecode automatically during the build. The output APK contains protected code.
ProGuard & R8 Compatibility
Shield is fully backward-compatible with ProGuard. Your existing proguard-rules.pro rules, ProGuard annotations (@androidx.annotation.Keep, @ProguardKeep), and mapping file workflows work with Shield out of the box — no migration or rewriting required. Shield also works alongside R8 for code shrinking. See R8 & ProGuard Compatibility for full details.
Requirements
| Requirement | Minimum |
|---|---|
| Android Gradle Plugin | 7.0+ (Transform API) or 8.0+ (Artifacts API) |
| Java | 11+ |
| Kotlin | 1.8+ (if using Kotlin) |
| minSdk | 21 |
| Internet | Required during build for license validation |
Next Steps
Quick Start
Step-by-step guide to protect your first Android application
Gradle Setup
Complete installation and repository configuration
Protections
Detailed guide to all available protections
Annotations
Fine-grained control with @Keep, @DoNotObfuscate, and @Exclude