MuntashirAkon/AppManager · error · Resources.NotFoundException
Resource ${name} of type ${type} is not found in package ${p
Error message
Resource ${name} of type ${type} is not found in package ${packageName} What it means
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.
Source
Thrown at app/src/main/java/io/github/muntashirakon/AppManager/utils/ResourceUtil.java:76
* 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());
}
@Nullable
public String packageName;
@Nullable
public String className;
@Nullable
public Resources resources;
public boolean loadResources(@NonNull PackageManager pm, @NonNull String packageName) {
try {View on GitHub (pinned to 0152f468fc)
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
Example fix
// before
ParsedResource r = ResourceUtil.getResourceFromName(pm, "com.example.app:string/missing");
// after
try {
r = ResourceUtil.getResourceFromName(pm, "com.example.app:string/missing");
} catch (Resources.NotFoundException e) {
r = ResourceUtil.getResourceFromName(pm, "com.example.app:string/default_label");
} Defensive patterns
Strategy: try-catch
Validate before calling
Resources res = pm.getResourcesForApplication(targetPackage);
if (res.getIdentifier(name, type, targetPackage) == 0) {
// resource missing: use fallback before calling getResourceFromName
} Type guard
boolean resourceExists(Resources res, String name, String type, String pkg) {
return res.getIdentifier(name, type, pkg) != 0;
} Try / catch
try {
parsed = ResourceUtil.getResourceFromName(pm, qualifiedName);
} catch (Resources.NotFoundException e) {
parsed = fallbackResource();
} Prevention
- 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
When it happens
Trigger: 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').
Common situations: 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.
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
- String resource ID ${stringRes}
- Package not found.
- No base backup found.
- Backup with name ${mBackupNames[0]} doesn't exist.
- Backup with name ${mBackupNames[i]} doesn't exist.
AI-assisted analysis of MuntashirAkon/AppManager@0152f468fc (2026-09-12).
Data as JSON: /api/errors/752acd3d7939279c.
Report an issue: GitHub.