{"record":{"id":"14347d611528e22e","repo":"MuntashirAkon/AppManager","slug":"apparently-the-install-wasn-t-complete-in-the-previous","errorCode":null,"errorMessage":"Apparently the install wasn't complete in the previous section.","messagePattern":"Apparently the install wasn't complete in the previous section\\.","errorType":"exception","errorClass":"BackupException","httpStatus":null,"severity":"error","filePath":"app/src/main/java/io/github/muntashirakon/AppManager/backup/RestoreOp.java","lineNumber":406,"sourceCode":"                    } else {\n                        statusMessage = \"Couldn't perform an installation\";\n                    }\n                    if (status.get() != null) {\n                        statusMessage += \": \" + status.get();\n                    } else statusMessage += \".\";\n                    throw new BackupException(statusMessage);\n                }\n            } finally {\n                deleteFiles(allApks);  // Clean up apk files\n            }\n            // Get package info, again\n            try {\n                mPackageInfo = PackageManagerCompat.getPackageInfo(mPackageName, GET_SIGNING_CERTIFICATES\n                        | PackageManagerCompat.MATCH_STATIC_SHARED_AND_SDK_LIBRARIES, mUserId);\n                mUid = Objects.requireNonNull(mPackageInfo.applicationInfo).uid;\n                mIsInstalled = true;\n            } catch (Exception e) {\n                throw new BackupException(\"Apparently the install wasn't complete in the previous section.\", e);\n            }\n        }\n    }\n\n    private void restoreKeyStore() throws BackupException {\n        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {\n            // keystore v2 is not supported.\n            Log.w(TAG, \"Ignoring KeyStore backups for %s\", mPackageName);\n            return;\n        }\n        if (mPackageInfo == null) {\n            throw new BackupException(\"KeyStore restore is requested but the app isn't installed.\");\n        }\n        Path[] keyStoreFiles = mBackupItem.getKeyStoreFiles();\n        if (keyStoreFiles.length == 0) {\n            throw new BackupException(\"KeyStore files should've existed but they didn't\");\n        }\n        if (!mRequestedFlags.skipSignatureCheck()) {","sourceCodeStart":388,"sourceCodeEnd":424,"githubUrl":"https://github.com/MuntashirAkon/AppManager/blob/0152f468fc9463ee02dc2ca83f6fe4989a2c4ca5/app/src/main/java/io/github/muntashirakon/AppManager/backup/RestoreOp.java#L388-L424","documentation":"After installing the APKs, restoreApkFiles re-queries PackageManagerCompat.getPackageInfo to confirm the package is now installed and to capture its UID. This error means the package could not be found even though installation was just attempted — i.e. the previous install step did not actually complete. AppManager throws this to signal an inconsistent restore state.","triggerScenarios":"getPackageInfo(mPackageName, GET_SIGNING_CERTIFICATES | MATCH_STATIC_SHARED_AND_SDK_LIBRARIES, mUserId) throws because the package is absent from the given user, immediately after the install call reported success or was skipped.","commonSituations":"The install in the previous section failed silently or was staged but never committed; installation targeted a different user than mUserId; the device removed the package between install and lookup; hidden/suspended package lookups failing on some OEM ROMs.","solutions":["Check logs from the install step (error 123 family) — fix the underlying installation failure first.","Verify mUserId matches the user the package was installed into.","Re-run the full restore; do not attempt KeyStore/data restore for a package that is not installed.","Confirm the package name in backup metadata matches the APK's actual package."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"try { pm.getPackageInfo(pkg, GET_SIGNING_CERTIFICATES | MATCH_STATIC_SHARED_AND_SDK_LIBRARIES, userId); } catch (Exception e) { /* package absent — do not proceed with data/keystore restore */ }","typeGuard":"boolean isInstalled(PackageInfo pi) { return pi != null && pi.applicationInfo != null; }","tryCatchPattern":"try { mPackageInfo = PackageManagerCompat.getPackageInfo(...); } catch (Exception e) { throw new BackupException(\"Apparently the install wasn't complete in the previous section.\", e); }","preventionTips":["Confirm install success status before the package-info re-query","Verify userId consistency across install and lookup calls","Never chain keystore/data restore after a failed install","Log installer session status for post-mortem"],"tags":["android","package-manager","restore-state"],"backgroundTag":"invalid-state-transition","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"}