{"record":{"id":"752acd3d7939279c","repo":"MuntashirAkon/AppManager","slug":"resource-name-of-type-type-is-not-found-in-package","errorCode":null,"errorMessage":"Resource ${name} of type ${type} is not found in package ${packageName}","messagePattern":"Resource (.+?) of type (.+?) is not found in package (.+?)","errorType":"exception","errorClass":"Resources.NotFoundException","httpStatus":null,"severity":"error","filePath":"app/src/main/java/io/github/muntashirakon/AppManager/utils/ResourceUtil.java","lineNumber":76,"sourceCode":"     * 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\n    @Nullable\n    public String packageName;\n    @Nullable\n    public String className;\n    @Nullable\n    public Resources resources;\n\n    public boolean loadResources(@NonNull PackageManager pm, @NonNull String packageName) {\n        try {","sourceCodeStart":58,"sourceCodeEnd":94,"githubUrl":"https://github.com/MuntashirAkon/AppManager/blob/0152f468fc9463ee02dc2ca83f6fe4989a2c4ca5/app/src/main/java/io/github/muntashirakon/AppManager/utils/ResourceUtil.java#L58-L94","documentation":"After splitting 'package:type/name', getResourceFromName resolves the numeric ID via Resources#getIdentifier(name, type, packageName). When the remote package's Resources cannot map the name/type combination to an identifier (getIdentifier returns 0), it throws Resources.NotFoundException(\"Resource <name> of type <type> is not found in package <packageName>\"). The name was well-formed; the resource simply does not exist in that package.","triggerScenarios":"Calling getResourceFromName(pm, 'pkg:string/foo') where package pkg is valid but has no string named foo, or the type segment is wrong (e.g. 'drawable' vs 'mipmap', 'raw' vs 'string').","commonSituations":"Targeting an app version that renamed or removed a resource; assuming a resource exists in a different app; typos in the type segment; resource only defined in a build variant/flavor not installed.","solutions":["Verify the resource exists in the target package (aapt dump resources or decompile) before lookup","Check the type segment spelling/case against the target package's R class","Catch Resources.NotFoundException and fall back to a known-good resource in your own package","Update to a target-app version whose resources match, or handle multiple candidate names"],"exampleFix":"// before\nParsedResource r = ResourceUtil.getResourceFromName(pm, \"com.example.app:string/missing\");\n// after\ntry {\n    r = ResourceUtil.getResourceFromName(pm, \"com.example.app:string/missing\");\n} catch (Resources.NotFoundException e) {\n    r = ResourceUtil.getResourceFromName(pm, \"com.example.app:string/default_label\");\n}","handlingStrategy":"try-catch","validationCode":"Resources res = pm.getResourcesForApplication(targetPackage);\nif (res.getIdentifier(name, type, targetPackage) == 0) {\n    // resource missing: use fallback before calling getResourceFromName\n}","typeGuard":"boolean resourceExists(Resources res, String name, String type, String pkg) {\n    return res.getIdentifier(name, type, pkg) != 0;\n}","tryCatchPattern":"try {\n    parsed = ResourceUtil.getResourceFromName(pm, qualifiedName);\n} catch (Resources.NotFoundException e) {\n    parsed = fallbackResource();\n}","preventionTips":["Pin lookups against a known target-app version; expect removals across updates","Keep a candidate list of resource names to try in order","Verify type spelling against the target package's R class"],"tags":["android","resources","not-found"],"backgroundTag":"resource-not-found","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"}