shwenzhang/AndResGuard · error · brut.androlib.AndrolibException
spec proguard name duplicate in a singal type
Error message
spec proguard name duplicate in a singal type %s, spec name: %s
What it means
ResType.putSpecResguardName throws this AndrolibException when the same proguard-resguard name is registered twice for one resource type. AndResGuard keeps a per-type set (specNames) of generated short names and requires them to be unique so obfuscated resource names do not collide in resources.arsc.
Solutions
- Find the duplicate mapping for the printed type and spec name and make names unique within that type.
- Deduplicate input mapping/whitelist entries before feeding them to AndResGuard.
- If running obfuscation twice, recreate ResType objects instead of reusing populated ones.
- If this is an intentional overwrite, check the set with contains() first and skip instead of adding.
Example fix
// before
resType.putSpecResguardName("a");
resType.putSpecResguardName("a"); // throws
// after
if (!usedNames.contains("a")) {
resType.putSpecResguardName("a");
} Defensive patterns
Strategy: validation
Validate before calling
Set<String> seen = new HashSet<>();
for (String name : newNames) {
if (!seen.add(name)) {
throw new IllegalArgumentException("duplicate resguard name: " + name);
}
} Try / catch
try {
resType.putSpecResguardName(name);
} catch (AndrolibException e) {
// duplicate name in this type: regenerate or skip
} Prevention
- Deduplicate mapping and whitelist files before obfuscation.
- Use a deterministic, unique name generator per type.
- Never reuse populated ResType instances across runs.
When it happens
Trigger: Calling putSpecResguardName(name) on a ResType that already contains that exact name — typically from a custom resguard naming strategy (whiteList / package renaming) that maps two resources in the same type to the same short name, or re-running the name-allocation code on already-populated ResType objects.
Common situations: Custom resource name mapping files with duplicate entries for one type; colliding whitelist entries; reusing ResType instances across two obfuscation runs without clearing specNames; non-deterministic name generator producing repeats.
Understand the failure class
Background: "invalid id" errors: invalid identifier format — why libraries reject IDs before lookup, and how to fix them — this error's family across 37 libraries.
Related errors
AI-assisted analysis of shwenzhang/AndResGuard@e4df245d82 (2026-09-12).
Data as JSON: /api/errors/290889ee3216e1c2.
Report an issue: GitHub.
Appendix: source
Thrown at AndResGuard-core/src/main/java/com/tencent/mm/androlib/res/data/ResType.java:40
public final class ResType {
private final String mName;
private final ResPackage mPackage;
private final HashSet<String> specNames;
public ResType(String name, ResPackage package_) {
this.mName = name;
this.mPackage = package_;
specNames = new HashSet<>();
}
public String getName() {
return mName;
}
public void putSpecResguardName(String name) throws AndrolibException {
if (specNames.contains(name)) {
throw new AndrolibException(String.format(
"spec proguard name duplicate in a singal type %s, spec name: %s\n",
getName(),
name
));
}
specNames.add(name);
}
@Override
public String toString() {
return mName;
}
}
View on GitHub (pinned to e4df245d82)