MuntashirAkon/AppManager · error · Resources.NotFoundException

No resource could be loaded.

Error message

No resource could be loaded.

What it means

ResourceUtil.getString resolves a string resource by name through the wrapped Resources instance. If the ResourceUtil was constructed without usable Resources (the internal resources field is null), it throws Resources.NotFoundException("No resource could be loaded.") before attempting identifier lookup. This signals that no target package/context resources are available at all, as opposed to a missing individual key.

Source

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

    public boolean loadAndroidResources() {
        this.packageName = "android";
        this.className = null;
        this.resources = Resources.getSystem();
        return true;
    }

    /**
     * Return the string value associated with a particular resource ID. It will be stripped of any styled text information.
     *
     * @param stringRes The desired resource identifier.
     * @return String The string data associated with the resource, stripped of styled text information.
     * @throws Resources.NotFoundException Throws NotFoundException if the given ID does not exist.
     */
    @NonNull
    @SuppressLint("DiscouragedApi")
    public String getString(@NonNull String stringRes) throws Resources.NotFoundException {
        if (resources == null) {
            throw new Resources.NotFoundException("No resource could be loaded.");
        }
        int intStringRes = resources.getIdentifier(stringRes, "string", packageName);
        if (intStringRes == 0) throw new Resources.NotFoundException("String resource ID " + stringRes);
        return this.resources.getString(intStringRes);
    }
}

View on GitHub (pinned to 0152f468fc)

Solutions

  1. Ensure the manifest declares <queries> entries for the target packages (Android 11+ package visibility)
  2. Verify the target package is installed (pm.getPackageInfo) before constructing ResourceUtil
  3. Check the construction path that sets resources; use a valid Context's getResources()
  4. Catch Resources.NotFoundException and fall back to a local string

Example fix

// before
String s = resourceUtil.getString("app_name");
// after
String s;
try {
    s = resourceUtil.getString("app_name");
} catch (Resources.NotFoundException e) {
    s = context.getString(R.string.app_name); // local fallback
}
Defensive patterns

Strategy: fallback

Validate before calling

try {
    pm.getPackageInfo(targetPackage, 0);
} catch (PackageManager.NameNotFoundException e) {
    // target package unavailable; use local resources
}

Type guard

boolean canLoadResources(PackageManager pm, String pkg) {
    try { pm.getPackageInfo(pkg, 0); return true; } catch (PackageManager.NameNotFoundException e) { return false; }
}

Try / catch

try {
    s = resourceUtil.getString(key);
} catch (Resources.NotFoundException e) {
    s = context.getString(R.string.fallback);
}

Prevention

When it happens

Trigger: Constructing ResourceUtil (e.g. forApp/forPackage variants) with a null Resources instance — package not installed, not visible due to package-visibility filtering (Android 11+ <queries>), or a failed context creation — then calling getString.

Common situations: Looking up strings from another app without the Android 11 package-visibility declaration in the manifest; querying an uninstalled package; passing a null package name/context during construction.

Understand the failure class

Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.

Related errors


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