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 runtime dependencies beyond a lightweight decryption library.
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.
The process is transparent to your development workflow: you configure which protections to enable, 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 reference proxying.
- 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:
Code Obfuscation
| Protection | DSL Property | What It Does |
|---|---|---|
| Name Obfuscation | nameObfuscation | Renames classes, methods, and fields to meaningless identifiers |
| Control Flow Obfuscation | controlFlowObfuscation | Inserts opaque predicates and restructures method logic |
| Reference Proxy | referenceProxy | Replaces direct method calls with proxy indirection layers |
Data Protection
| Protection | DSL Property | What It Does |
|---|---|---|
| String Encryption | stringEncryption | Encrypts string literals and decrypts them at runtime |
| Constant Mutation | constantMutation | Transforms numeric constants into equivalent expressions |
| Resource Protection | resourceProtection | Protects application resources from extraction and analysis |
Runtime Protections
| Protection | DSL Property | What It Does |
|---|---|---|
| Anti-Debug | antiDebug | Detects debuggers, Frida, Xposed, and instrumentation tools |
| Anti-Tamper | antiTamper | Verifies application integrity and detects package modifications |
| Debug Removal | debugRemoval | Strips debug metadata from compiled bytecode |
Quick Example
Add Shield to an existing Android project in three steps:
1. Add the plugin
// app/build.gradle
plugins {
id 'com.android.application'
id 'org.jetbrains.kotlin.android'
id 'com.bytehide.shield' version '1.0.0'
}// app/build.gradle
plugins {
id 'com.android.application'
id 'org.jetbrains.kotlin.android'
id 'com.bytehide.shield' version '1.0.0'
}2. Configure protections
shield {
projectToken = "your-project-token"
protections {
stringEncryption = true
constantMutation = true
debugRemoval = true
antiDebug = true
}
excludedPackages = ['android', 'androidx', 'kotlin', 'kotlinx']
}shield {
projectToken = "your-project-token"
protections {
stringEncryption = true
constantMutation = true
debugRemoval = true
antiDebug = true
}
excludedPackages = ['android', 'androidx', 'kotlin', 'kotlinx']
}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 9 available protections
Annotations
Fine-grained control with @Keep, @DoNotObfuscate, and @Exclude