{"record":{"id":"29cee4bb25e18160","repo":"MuntashirAkon/AppManager","slug":"resource-resname-is-not-found","errorCode":null,"errorMessage":"Resource ${resName} is not found.","messagePattern":"Resource (.+?) is not found\\.","errorType":"exception","errorClass":"Resources.NotFoundException","httpStatus":null,"severity":"error","filePath":"app/src/main/java/io/github/muntashirakon/AppManager/utils/ResourceUtil.java","lineNumber":67,"sourceCode":"        public Drawable getDrawable(@Nullable Resources.Theme theme) {\n            return ResourcesCompat.getDrawable(mRes, mResId, theme);\n        }\n    }\n\n    /**\n     * Parse a resource name having the following format:\n     * <p>\n     * <code>\n     * package-name:type/res-name\n     * </code>\n     */\n    @NonNull\n    public static ParsedResource getResourceFromName(@NonNull PackageManager pm, @NonNull String resName)\n            throws PackageManager.NameNotFoundException, Resources.NotFoundException {\n        int indexOfColon = resName.indexOf(':');\n        int indexOfSlash = resName.indexOf('/');\n        if (indexOfColon == -1 || indexOfSlash == -1) {\n            throw new Resources.NotFoundException(\"Resource \" + resName + \" is not found.\");\n        }\n        String packageName = resName.substring(0, indexOfColon);\n        String type = resName.substring(indexOfColon + 1, indexOfSlash);\n        String name = resName.substring(indexOfSlash + 1);\n        Resources res = pm.getResourcesForApplication(packageName);\n        @SuppressLint(\"DiscouragedApi\")\n        int resId = res.getIdentifier(name, type, packageName);\n        if (resId == 0) {\n            throw new Resources.NotFoundException(\"Resource \" + name + \" of type \" + type + \" is not found in package \" + packageName);\n        }\n        return new ParsedResource(packageName, res, resId);\n    }\n\n    @SuppressLint(\"DiscouragedApi\")\n    public static int getRawDataId(@NonNull Context context, @NonNull String name) {\n        return context.getResources().getIdentifier(name, \"raw\", context.getPackageName());\n    }\n","sourceCodeStart":49,"sourceCodeEnd":85,"githubUrl":"https://github.com/MuntashirAkon/AppManager/blob/0152f468fc9463ee02dc2ca83f6fe4989a2c4ca5/app/src/main/java/io/github/muntashirakon/AppManager/utils/ResourceUtil.java#L49-L85","documentation":"ResourceUtil.getResourceFromName parses a fully qualified resource name of the form 'package:type/name'. If the input string lacks either the ':' separator (package boundary) or the '/' separator (type/name boundary), it throws Resources.NotFoundException(\"Resource <resName> is not found.\") immediately, before any package lookup. The ${resName} in the docs is a literal template — the actual message interpolates the input string.","triggerScenarios":"Passing a resource name to getResourceFromName that is not in 'package:type/name' format, e.g. 'type/name' (no package), 'package:type' (no name), or a bare name like 'app_name'.","commonSituations":"Users pasting resource names from other tools that omit the package prefix; input from configuration files expecting short resource names; locale-related string handling that dropped part of the qualified name.","solutions":["Validate the input matches 'package:type/name' (contains both ':' and '/') before calling","Prepend the expected package if the caller supplies only 'type/name'","Catch Resources.NotFoundException and show the expected format to the user"],"exampleFix":"// before\nParsedResource r = ResourceUtil.getResourceFromName(pm, \"string/app_name\");\n// after\nString resName = \"string/app_name\";\nif (!resName.contains(\":\")) resName = targetPackage + \":\" + resName;\nParsedResource r = ResourceUtil.getResourceFromName(pm, resName);","handlingStrategy":"validation","validationCode":"if (resName.indexOf(':') == -1 || resName.indexOf('/') == -1) {\n    throw new IllegalArgumentException(\"Expected 'package:type/name', got: \" + resName);\n}","typeGuard":"boolean isQualifiedResName(String resName) {\n    return resName != null && resName.contains(\":\") && resName.contains(\"/\");\n}","tryCatchPattern":"try {\n    res = ResourceUtil.getResourceFromName(pm, resName);\n} catch (Resources.NotFoundException e) {\n    promptUserForQualifiedFormat(resName);\n}","preventionTips":["Normalize input to 'package:type/name' before lookup (auto-prefix current package if ': ' missing)","Reject malformed names at the input UI, not at lookup time","Document the expected format wherever the string is collected"],"tags":["android","resources","parsing","format"],"backgroundTag":"invalid-argument-format","analyzedSha":"0152f468fc9463ee02dc2ca83f6fe4989a2c4ca5","analyzedAt":"2026-09-12T14:03:37.243Z","contentChangedAt":"2026-09-12T14:03:37.243Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}