MuntashirAkon/AppManager · error · ApkFile.ApkFileException

Package not installed.

Error message

Package not installed.

What it means

setPackage() in AppDetailsViewModel resolves the package via PackageManager and requires a non-null PackageInfo before it can build an ApkSource. A null PackageInfo means the package name does not resolve to any installed app for the current user, so the ViewModel cannot display details and throws ApkFileException. The catch block posts null to mPackageInfoLiveData so the UI shows the package as unavailable.

Source

Thrown at app/src/main/java/io/github/muntashirakon/AppManager/details/AppDetailsViewModel.java:243

            } finally {
                mPackageInfoWatcher.countDown();
            }
        });
        return mPackageInfoLiveData;
    }

    @UiThread
    @NonNull
    public LiveData<PackageInfo> setPackage(@NonNull String packageName) {
        mExternalApk = false;
        mExecutor.submit(() -> {
            try {
                Log.d(TAG, "Package name is being set");
                setPackageName(packageName);
                // TODO: 23/5/21 The app could be “data only”
                setPackageInfo(false);
                PackageInfo pi = getPackageInfo();
                if (pi == null) throw new ApkFile.ApkFileException("Package not installed.");
                mApkSource = ApkSource.getApkSource(pi.applicationInfo);
                mApkFile = mApkSource.resolve();
                mPackageInfoLiveData.postValue(pi);
            } catch (Throwable th) {
                Log.e(TAG, "Could not fetch package info.", th);
                mPackageInfoLiveData.postValue(null);
            } finally {
                mPackageInfoWatcher.countDown();
            }
        });
        return mPackageInfoLiveData;
    }

    @AnyThread
    public void setUserId(@UserIdInt int userId) {
        mUserId = userId;
    }

View on GitHub (pinned to 0152f468fc)

Solutions

  1. Check PackageManager.getPackageInfo(packageName, ...) for null before calling setPackage, or catch ApkFileException and show a 'not installed' message
  2. Verify the package name spelling and that the app is installed for the target user ID
  3. If handling data-only apps, use the code path that supports ApplicationInfoCompat.isInstalled checks rather than this one
  4. Refresh the package list before opening details so stale names are filtered

Example fix

// before
viewModel.setPackage("com.example.app"); // throws ApkFileException if not installed
// after
try {
    viewModel.setPackage("com.example.app");
} catch (ApkFile.ApkFileException e) {
    showPackageNotInstalledToast();
}
Defensive patterns

Strategy: try-catch

Validate before calling

PackageInfo pi = pm.getPackageInfo(pkgName, 0);
boolean installed = pi != null;

Type guard

boolean isInstalled(PackageManager pm, String pkg) {
    try { return pm.getPackageInfo(pkg, 0) != null; } catch (PackageManager.NameNotFoundException e) { return false; }
}

Try / catch

try {
    viewModel.setPackage(pkgName);
} catch (ApkFile.ApkFileException e) {
    showNotInstalledError(pkgName);
}

Prevention

When it happens

Trigger: Calling setPackage(packageName) with a name that is not installed for the queried user; the package was uninstalled while the details screen was open; querying with a package name that exists only as archived/data-only; typo in the package name.

Common situations: Deep link or shortcut pointing at an app the user has since removed; handling an APK path scan where the reported package name isn't actually installed; running on a work profile/user where the app isn't installed.

Understand the failure class

Background: "Not found" and "does not exist" errors: why "Task not found", "No such folder", and "Can't find" fire when a lookup comes back empty — this error's family across 14 libraries.

Related errors


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