/

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

Groovy
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

Java
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

Java
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:

ModePatternExampleDescription
LETTERSSequential lettersa, b, ..., z, aa, abDefault mode. Produces the shortest names
SEQUENTIALSequential namesa, b, c, ..., z, aaProGuard-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:

CODE
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) -> c

What 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
  • @Keep annotated elements, any element with Shield's @Keep or AndroidX @Keep annotation
  • @DoNotObfuscate elements, 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:

Kotlin
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.


Previous
Overview