MuntashirAkon/AppManager · error · Resources.NotFoundException

Resource ${resName} is not found.

Error message

Resource ${resName} is not found.

What it means

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.

Source

Thrown at app/src/main/java/io/github/muntashirakon/AppManager/utils/ResourceUtil.java:67

        public Drawable getDrawable(@Nullable Resources.Theme theme) {
            return ResourcesCompat.getDrawable(mRes, mResId, theme);
        }
    }

    /**
     * Parse a resource name having the following format:
     * <p>
     * <code>
     * package-name:type/res-name
     * </code>
     */
    @NonNull
    public static ParsedResource getResourceFromName(@NonNull PackageManager pm, @NonNull String resName)
            throws PackageManager.NameNotFoundException, Resources.NotFoundException {
        int indexOfColon = resName.indexOf(':');
        int indexOfSlash = resName.indexOf('/');
        if (indexOfColon == -1 || indexOfSlash == -1) {
            throw new Resources.NotFoundException("Resource " + resName + " is not found.");
        }
        String packageName = resName.substring(0, indexOfColon);
        String type = resName.substring(indexOfColon + 1, indexOfSlash);
        String name = resName.substring(indexOfSlash + 1);
        Resources res = pm.getResourcesForApplication(packageName);
        @SuppressLint("DiscouragedApi")
        int resId = res.getIdentifier(name, type, packageName);
        if (resId == 0) {
            throw new Resources.NotFoundException("Resource " + name + " of type " + type + " is not found in package " + packageName);
        }
        return new ParsedResource(packageName, res, resId);
    }

    @SuppressLint("DiscouragedApi")
    public static int getRawDataId(@NonNull Context context, @NonNull String name) {
        return context.getResources().getIdentifier(name, "raw", context.getPackageName());
    }

View on GitHub (pinned to 0152f468fc)

Solutions

  1. Validate the input matches 'package:type/name' (contains both ':' and '/') before calling
  2. Prepend the expected package if the caller supplies only 'type/name'
  3. Catch Resources.NotFoundException and show the expected format to the user

Example fix

// before
ParsedResource r = ResourceUtil.getResourceFromName(pm, "string/app_name");
// after
String resName = "string/app_name";
if (!resName.contains(":")) resName = targetPackage + ":" + resName;
ParsedResource r = ResourceUtil.getResourceFromName(pm, resName);
Defensive patterns

Strategy: validation

Validate before calling

if (resName.indexOf(':') == -1 || resName.indexOf('/') == -1) {
    throw new IllegalArgumentException("Expected 'package:type/name', got: " + resName);
}

Type guard

boolean isQualifiedResName(String resName) {
    return resName != null && resName.contains(":") && resName.contains("/");
}

Try / catch

try {
    res = ResourceUtil.getResourceFromName(pm, resName);
} catch (Resources.NotFoundException e) {
    promptUserForQualifiedFormat(resName);
}

Prevention

When it happens

Trigger: 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'.

Common situations: 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.

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


AI-assisted analysis of MuntashirAkon/AppManager@0152f468fc (2026-09-12). Data as JSON: /api/errors/29cee4bb25e18160. Report an issue: GitHub.