MuntashirAkon/AppManager · error · IllegalArgumentException
Package name not set for install-existing.
Error message
Package name not set for install-existing.
What it means
PackageInstallerViewModel.loadPackageInfo() handles install-existing queue items (reinstalling a package already present on the device). Such an item must carry the target package name; if ApkQueueItem.getPackageName() returns null an IllegalArgumentException is thrown because the installed package info cannot be looked up.
Source
Thrown at app/src/main/java/io/github/muntashirakon/AppManager/apk/installer/PackageInstallerViewModel.java:278
if (mSelectedSplits.isEmpty()) {
throw new IllegalArgumentException("No splits selected.");
}
return new ArrayList<>(mSelectedSplits);
}
return new ArrayList<>(Collections.singletonList(apkFile.getBaseEntry().id));
}
@WorkerThread
@NonNull
private PackageParseResult loadPackageInfo(@NonNull ApkQueueItem apkQueueItem) throws Throwable {
ApkSource apkSource;
ApkFile apkFile = null;
try {
PackageInfo installedPackageInfo = null;
if (apkQueueItem.isInstallExisting()) {
String packageName = apkQueueItem.getPackageName();
if (packageName == null) {
throw new IllegalArgumentException("Package name not set for install-existing.");
}
installedPackageInfo = loadInstalledPackageInfo(packageName);
apkSource = ApkSource.getApkSource(installedPackageInfo.applicationInfo);
} else {
apkSource = apkQueueItem.getApkSource();
if (apkSource == null) {
throw new IllegalArgumentException("Invalid queue item.");
}
}
apkFile = apkSource.resolve();
PackageInfo newPackageInfo = loadNewPackageInfo(apkFile);
String packageName = newPackageInfo.packageName;
throwIfInterrupted();
if (installedPackageInfo == null) {
try {
installedPackageInfo = loadInstalledPackageInfo(packageName);
} catch (PackageManager.NameNotFoundException ignore) {
}View on GitHub (pinned to 0152f468fc)
Solutions
- Set the package name on the queue item before using install-existing mode
- If installing from an APK file instead, set installExisting=false and provide an apkSource
- Validate the serialized JSON contains package_name when install_existing is true before constructing the item
- Catch IllegalArgumentException around ViewModel setup and surface a configuration error to the caller
Example fix
// before
ApkQueueItem item = new ApkQueueItem();
item.setInstallExisting(true);
vm.loadPackageInfo(item); // throws
// after
ApkQueueItem item = new ApkQueueItem();
item.setInstallExisting(true);
item.setPackageName("com.example.app");
vm.loadPackageInfo(item); Defensive patterns
Strategy: validation
Validate before calling
if (item.isInstallExisting() && (item.getPackageName() == null || item.getPackageName().isEmpty())) {
throw new IllegalStateException("install-existing queue item requires a package name.");
} Type guard
boolean isValidInstallExisting(ApkQueueItem item) {
return !item.isInstallExisting()
|| (item.getPackageName() != null && !item.getPackageName().isEmpty());
} Try / catch
try {
vm.loadPackageInfo(item);
} catch (IllegalArgumentException e) {
if (e.getMessage().contains("Package name")) {
showError("Queue item is missing the package name for install-existing replay.");
}
} Prevention
- Always set packageName together with installExisting=true
- Persist package_name in session JSON for replays
- Use install-existing only for packages already installed; otherwise use an apkSource
When it happens
Trigger: Creating an ApkQueueItem with mInstallExisting=true but never setting mPackageName, then passing it to the installer ViewModel — e.g. JSON deserialization of a replay session missing the package_name field.
Common situations: Restoring a queued install-existing replay from JSON where package_name was not persisted; programmatic construction of an install-existing queue item that only set installExisting=true; a caller mistakenly using install-existing mode for a fresh APK install (which needs apkSource, not packageName).
Understand the failure class
Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.
Related errors
- APK source is missing.
- Selected APK splits are missing.
- No splits selected.
- Invalid queue item.
- "manifest" has duplicate "application" tags.
AI-assisted analysis of MuntashirAkon/AppManager@0152f468fc (2026-09-12).
Data as JSON: /api/errors/c0c0afba0450ce89.
Report an issue: GitHub.