shwenzhang/AndResGuard · error
please write the full package name,eg…
Error message
please write the full package name,eg com.tencent.mm.R.drawable.dfdf, but yours %s
What it means
addWhiteList throws this IOException when a whitelist entry has no ".R." marker, meaning it is not written as a fully qualified resource name like com.example.app.R.drawable.icon. The parser uses indexOf(".R.") to split the package name from the resource type and name; without it the entry cannot be decomposed into the package/type/name triple the whitelist map requires.
Solutions
- Rewrite the whitelist entry as the full qualified name: <package>.R.<type>.<name>, e.g. com.example.app.R.drawable.icon
- Check the value for typos in the package name — the literal substring .R. must be present
- If you intended to keep a whole resource file path, use the correct format for your AndResGuard version (newer versions accept file paths in whitelist via different tooling)
Example fix
// before (config.xml) <item value="res/drawable/ic_launcher"/> // after (config.xml) <item value="com.example.app.R.drawable.ic_launcher"/>
Defensive patterns
Strategy: validation
Validate before calling
String v = itemElement.getAttribute("value");
if (v.indexOf(".R.") == -1) {
throw new IllegalStateException("whitelist entry must be fully qualified like com.example.app.R.drawable.icon, got: " + v);
} Try / catch
try {
new Configuration(configFile, ...);
} catch (IOException e) {
if (e.getMessage().startsWith("please write the full package name")) {
// extract the offending item from the message and rewrite it as <pkg>.R.<type>.<name>
}
throw e;
} Prevention
- Always use Java-style qualified resource names (com.pkg.R.type.name) in whitelist XML, not res/ file paths
- Grep your config for values containing 'res/' to catch path-style entries early
- Copy the exact resource name from R.java / lint output rather than typing it
When it happens
Trigger: A <item value="..."/> under <whitelist> contains a resource path with only slashes (res/drawable/icon), a bare resource name (icon), or a package name typo that omits the .R. segment; addWhiteList computes item.indexOf(".R.") == -1 and throws.
Common situations: Users copying AAPT resource file paths (res/drawable-hdpi/foo.png) instead of the fully qualified Java resource names into the whitelist; mixing Gradle resourceproguardOptions whitelist syntax (which accepts different forms) with the old XML config syntax.
Understand the failure class
Background: "Invalid ... format", "must be in format X", "does not look like a ..." — invalid argument format errors across CLI tools and libraries — this error's family across 17 libraries.
Related errors
- Invalid config file: Missing required attribute
- Invalid config file: Missing required attribute
- the old mapping file packagename is malformed, it should be…
- Failed to obtain key with alias
- entry " " does not contain certificates
AI-assisted analysis of shwenzhang/AndResGuard@e4df245d82 (2026-09-12).
Data as JSON: /api/errors/26e26ca8d73efc4f.
Report an issue: GitHub.
Appendix: source
Thrown at AndResGuard-core/src/main/java/com/tencent/mm/resourceproguard/Configuration.java:270
Node child = childNodes.item(j);
if (child.getNodeType() == Node.ELEMENT_NODE) {
Element check = (Element) child;
String vaule = check.getAttribute(ATTR_VALUE);
addWhiteList(vaule);
}
}
}
}
private void addWhiteList(String item) throws IOException {
if (item.length() == 0) {
throw new IOException("Invalid config file: Missing required attribute " + ATTR_VALUE);
}
int packagePos = item.indexOf(".R.");
if (packagePos == -1) {
throw new IOException(String.format("please write the full package name,eg com.tencent.mm.R.drawable.dfdf, but yours %s\n",
item
));
}
//先去掉空格
item = item.trim();
String packageName = item.substring(0, packagePos);
//不能通过lastDot
int nextDot = item.indexOf(".", packagePos + 3);
String typeName = item.substring(packagePos + 3, nextDot);
String name = item.substring(nextDot + 1);
HashMap<String, HashSet<Pattern>> typeMap;
if (mWhiteList.containsKey(packageName)) {
typeMap = mWhiteList.get(packageName);
} else {
typeMap = new HashMap<>();
}
View on GitHub (pinned to e4df245d82)