Name Obfuscation
Protection ID: nameObfuscation
Name Obfuscation renames classes, methods, and fields to short, meaningless identifiers. A class named PaymentProcessor with a method chargeCustomer becomes a.b with method c, making decompiled code extremely difficult to understand.
Configuration
shield {
protections {
nameObfuscation = true
}
}shield {
protections {
nameObfuscation = true
}
}If R8 is enabled (minifyEnabled true), set nameObfuscation = false to avoid conflicts. See R8 Compatibility.
How It Works
Name obfuscation replaces all meaningful identifiers in your code (class names, method names, field names, package names) with short, meaningless alternatives. This removes the semantic information that reverse engineers rely on to understand what each piece of code does.
The protection analyzes the entire class hierarchy to ensure that renamed elements remain consistent across inheritance chains, interface implementations, and cross-class references.
Before Shield
package com.example.payment;
public class PaymentProcessor {
private String apiKey;
private PaymentGateway gateway;
public PaymentResult chargeCustomer(String customerId, double amount) {
return gateway.processPayment(apiKey, customerId, amount);
}
}package com.example.payment;
public class PaymentProcessor {
private String apiKey;
private PaymentGateway gateway;
public PaymentResult chargeCustomer(String customerId, double amount) {
return gateway.processPayment(apiKey, customerId, amount);
}
}After Shield
package a;
public class b {
private String d;
private e f;
public g c(String h, double i) {
return f.j(d, h, i);
}
}package a;
public class b {
private String d;
private e f;
public g c(String h, double i) {
return f.j(d, h, i);
}
}Naming Modes
Shield supports two naming modes:
| Mode | Pattern | Example | Description |
|---|---|---|---|
| LETTERS | Sequential letters | a, b, ..., z, aa, ab | Default mode. Produces the shortest names |
| SEQUENTIAL | Sequential names | a, b, c, ..., z, aa | ProGuard-compatible sequential naming |
Mapping File
When name obfuscation is enabled, Shield generates a mapping file in ProGuard format. This file maps obfuscated names back to original names and is required for deobfuscating crash reports and stack traces, debugging production issues, and Firebase Crashlytics integration.
The mapping file is automatically uploaded to the ByteHide Cloud Panel. See Mapping Files for details.
Example mapping output:
com.example.payment.PaymentProcessor -> a.b:
java.lang.String apiKey -> d
com.example.payment.PaymentGateway gateway -> f
com.example.payment.PaymentResult chargeCustomer(java.lang.String,double) -> ccom.example.payment.PaymentProcessor -> a.b:
java.lang.String apiKey -> d
com.example.payment.PaymentGateway gateway -> f
com.example.payment.PaymentResult chargeCustomer(java.lang.String,double) -> cWhat Gets Preserved
Shield automatically preserves names that must remain unchanged:
- Entry points such as
Application,Activity,Service,BroadcastReceiver,ContentProvider - Android manifest references, classes referenced in
AndroidManifest.xml @Keepannotated elements, any element with Shield's@Keepor AndroidX@Keepannotation@DoNotObfuscateelements, elements marked to preserve names only- Public API surfaces (configurable for library modules)
Kotlin Considerations
Kotlin reflection relies on metadata annotations. If your code uses ::class, KClass, or KFunction, apply @DoNotObfuscate to the affected classes:
import com.bytehide.shield.annotations.DoNotObfuscate
@DoNotObfuscate
data class User(val name: String, val email: String)import com.bytehide.shield.annotations.DoNotObfuscate
@DoNotObfuscate
data class User(val name: String, val email: String)Without this, Kotlin reflection may fail because property names in kotlin.Metadata no longer match the renamed fields.
When to Use
Name obfuscation is one of the most effective protections against reverse engineering. It is recommended for all production builds where R8 name obfuscation is not already enabled. If R8 is handling name obfuscation, disable Shield's to avoid conflicts and let Shield focus on the protections R8 does not provide.
Related
- R8 Compatibility - Avoiding conflicts with R8's renaming
- Mapping Files - Using the mapping file for deobfuscation
- Annotations - Preserving specific names
- Protections Overview - All available protections