{"record":{"id":"87b7e87682b986f5","repo":"LSPosed/LSPosed","slug":"pkg-type-name","errorCode":null,"errorMessage":"${pkg}:${type}/${name}","messagePattern":"\\$\\{pkg\\}:\\$\\{type\\}/\\$\\{name\\}","errorType":"exception","errorClass":"Resources.NotFoundException","httpStatus":null,"severity":"error","filePath":"core/src/main/java/android/content/res/XResources.java","lineNumber":507,"sourceCode":"\t *\n\t * <p><i>\n\t *    * Auto-boxing allows you to use literals like {@code 123} where an {@link Integer} is\n\t *      accepted, so you don't neeed to call methods like {@link Integer#valueOf(int)} manually.<br>\n\t *    ** Some of these methods have multiple variants, only one of them is mentioned here.\n\t * </i>\n\t *\n\t * @param pkg The package name, e.g. {@code com.example.myapplication}.\n\t *            See {@link #getResourcePackageName}.\n\t * @param type The type name, e.g. {@code string}.\n\t *            See {@link #getResourceTypeName}.\n\t * @param name The entry name, e.g. {@code app_name}.\n\t *            See {@link #getResourceEntryName}.\n\t * @param replacement The replacement.\n\t */\n\tpublic void setReplacement(String pkg, String type, String name, Object replacement) {\n\t\tint id = getIdentifier(name, type, pkg);\n\t\tif (id == 0)\n\t\t\tthrow new NotFoundException(pkg + \":\" + type + \"/\" + name);\n\t\tsetReplacement(id, replacement, this);\n\t}\n\n\t/**\n\t * Sets a replacement for an individual Android framework resource (in the {@code android} package).\n\t * See {@link #setSystemWideReplacement(String, String, String, Object)}.\n\t *\n\t * @param id The ID of the resource which should be replaced.\n\t * @param replacement The replacement.\n\t */\n\tpublic static void setSystemWideReplacement(int id, Object replacement) {\n\t\tsetReplacement(id, replacement, null);\n\t}\n\n\t/**\n\t * Sets a replacement for an individual Android framework resource (in the {@code android} package).\n\t * See {@link #setSystemWideReplacement(String, String, String, Object)}.\n\t *","sourceCodeStart":489,"sourceCodeEnd":525,"githubUrl":"https://github.com/LSPosed/LSPosed/blob/df74d83eb03a44cc6ad268841ac2ada28d077c77/core/src/main/java/android/content/res/XResources.java#L489-L525","documentation":"XResources.setReplacement(pkg, type, name, replacement) throws Resources.NotFoundException('<pkg>:<type>/<name>') when getIdentifier(name, type, pkg) returns 0, i.e. the module/app resource table contains no entry with that triple. The message concatenates the exact triple used for lookup, so it names precisely what was missing.","triggerScenarios":"Calling setReplacement(\"com.example.app\", \"string\", \"app_name\", \"X\") when the target app has no resource named app_name of type string in that package — typo in the name, wrong package, or wrong type (e.g. 'color' vs 'drawable').","commonSituations":"Target app was updated and the resource was renamed/removed; hardcoding names that differ across app versions or build flavors (debug vs release); assuming a framework id exists in the app's package.","solutions":["Verify the identifier first: int id = res.getIdentifier(name, type, pkg); skip if id == 0.","Dump the target app's resources (aapt2 dump resources app.apk or apktool) and correct the name/type.","Prefer numeric resource IDs captured at build time for version-sensitive targets.","Guard replacement setup per app version if names diverge."],"exampleFix":"// before\nres.setReplacement(\"com.example.app\", \"string\", \"app_name\", \"Modded\"); // NotFoundException if absent\n// after\nint id = res.getIdentifier(\"app_name\", \"string\", \"com.example.app\");\nif (id != 0) res.setReplacement(id, \"Modded\", res);","handlingStrategy":"validation","validationCode":"int id = res.getIdentifier(name, type, pkg);\nif (id != 0) res.setReplacement(id, replacement, res);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Resolve-by-name then check id != 0 before every replacement.","Refresh resource names against the current target APK after app updates."],"tags":["xposed","resources","resource-not-found","api-misuse"],"backgroundTag":null,"analyzedSha":"df74d83eb03a44cc6ad268841ac2ada28d077c77","analyzedAt":"2026-08-14T10:46:48.326Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}