{"record":{"id":"6a95c88896b3a7aa","repo":"MuntashirAkon/AppManager","slug":"package-not-installed","errorCode":null,"errorMessage":"Package not installed.","messagePattern":"Package not installed\\.","errorType":"exception","errorClass":"ApkFile.ApkFileException","httpStatus":null,"severity":"error","filePath":"app/src/main/java/io/github/muntashirakon/AppManager/details/AppDetailsViewModel.java","lineNumber":243,"sourceCode":"            } finally {\n                mPackageInfoWatcher.countDown();\n            }\n        });\n        return mPackageInfoLiveData;\n    }\n\n    @UiThread\n    @NonNull\n    public LiveData<PackageInfo> setPackage(@NonNull String packageName) {\n        mExternalApk = false;\n        mExecutor.submit(() -> {\n            try {\n                Log.d(TAG, \"Package name is being set\");\n                setPackageName(packageName);\n                // TODO: 23/5/21 The app could be “data only”\n                setPackageInfo(false);\n                PackageInfo pi = getPackageInfo();\n                if (pi == null) throw new ApkFile.ApkFileException(\"Package not installed.\");\n                mApkSource = ApkSource.getApkSource(pi.applicationInfo);\n                mApkFile = mApkSource.resolve();\n                mPackageInfoLiveData.postValue(pi);\n            } catch (Throwable th) {\n                Log.e(TAG, \"Could not fetch package info.\", th);\n                mPackageInfoLiveData.postValue(null);\n            } finally {\n                mPackageInfoWatcher.countDown();\n            }\n        });\n        return mPackageInfoLiveData;\n    }\n\n    @AnyThread\n    public void setUserId(@UserIdInt int userId) {\n        mUserId = userId;\n    }\n","sourceCodeStart":225,"sourceCodeEnd":261,"githubUrl":"https://github.com/MuntashirAkon/AppManager/blob/0152f468fc9463ee02dc2ca83f6fe4989a2c4ca5/app/src/main/java/io/github/muntashirakon/AppManager/details/AppDetailsViewModel.java#L225-L261","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Check PackageManager.getPackageInfo(packageName, ...) for null before calling setPackage, or catch ApkFileException and show a 'not installed' message","Verify the package name spelling and that the app is installed for the target user ID","If handling data-only apps, use the code path that supports ApplicationInfoCompat.isInstalled checks rather than this one","Refresh the package list before opening details so stale names are filtered"],"exampleFix":"// before\nviewModel.setPackage(\"com.example.app\"); // throws ApkFileException if not installed\n// after\ntry {\n    viewModel.setPackage(\"com.example.app\");\n} catch (ApkFile.ApkFileException e) {\n    showPackageNotInstalledToast();\n}","handlingStrategy":"try-catch","validationCode":"PackageInfo pi = pm.getPackageInfo(pkgName, 0);\nboolean installed = pi != null;","typeGuard":"boolean isInstalled(PackageManager pm, String pkg) {\n    try { return pm.getPackageInfo(pkg, 0) != null; } catch (PackageManager.NameNotFoundException e) { return false; }\n}","tryCatchPattern":"try {\n    viewModel.setPackage(pkgName);\n} catch (ApkFile.ApkFileException e) {\n    showNotInstalledError(pkgName);\n}","preventionTips":["Verify installation for the target user before opening details","Filter shortcuts/deep links against currently installed packages","Refresh package lists after install/uninstall events (PACKAGE_ADDED/REMOVED receivers)"],"tags":["android","package-manager","not-installed"],"backgroundTag":"entity-not-found","analyzedSha":"0152f468fc9463ee02dc2ca83f6fe4989a2c4ca5","analyzedAt":"2026-09-12T14:03:37.243Z","contentChangedAt":"2026-09-12T14:03:37.243Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}