{"record":{"id":"c628b3d9061c5877","repo":"MuntashirAkon/AppManager","slug":"misc-restore-is-requested-but-the-app-isn-t-installed","errorCode":null,"errorMessage":"Misc restore is requested but the app isn't installed.","messagePattern":"Misc restore is requested but the app isn't installed\\.","errorType":"exception","errorClass":"BackupException","httpStatus":null,"severity":"error","filePath":"app/src/main/java/io/github/muntashirakon/AppManager/backup/RestoreOp.java","lineNumber":625,"sourceCode":"        }\n        // Decrypt data\n        try {\n            dataFiles = mBackupItem.decrypt(dataFiles);\n        } catch (IOException e) {\n            throw new BackupException(\"Failed to decrypt \" + Arrays.toString(dataFiles), e);\n        }\n        // Restore data\n        try (InputStream is = dataFiles[0].openInputStream()) {\n            ParcelFileDescriptor fd = ParcelFileDescriptorUtil.pipeFrom(is);\n            BackupCompat.adbRestore(mUserId, fd);\n        } catch (Throwable th) {\n            throw new BackupException(\"Failed to restore ADB data\", th);\n        }\n    }\n\n    private synchronized void restoreExtras() throws BackupException {\n        if (!mIsInstalled) {\n            throw new BackupException(\"Misc restore is requested but the app isn't installed.\");\n        }\n        PseudoRules rules = new PseudoRules(mPackageName, mUserId);\n        // Backward compatibility for restoring permissions\n        loadMiscRules(rules);\n        // Apply rules\n        List<RuleEntry> entries = rules.getAll();\n        AppOpsManagerCompat appOpsManager = new AppOpsManagerCompat();\n        INotificationManager notificationManager = INotificationManager.Stub.asInterface(ProxyBinder.getService(Context.NOTIFICATION_SERVICE));\n        boolean magiskHideAvailable = MagiskHide.available();\n        boolean canModifyAppOpMode = SelfPermissions.canModifyAppOpMode();\n        boolean canChangeNetPolicy = SelfPermissions.checkSelfOrRemotePermission(ManifestCompat.permission.MANAGE_NETWORK_POLICY);\n        for (RuleEntry entry : entries) {\n            try {\n                switch (entry.type) {\n                    case APP_OP:\n                        if (canModifyAppOpMode) {\n                            appOpsManager.setMode(Integer.parseInt(entry.name), mUid, mPackageName,\n                                    ((AppOpRule) entry).getMode());","sourceCodeStart":607,"sourceCodeEnd":643,"githubUrl":"https://github.com/MuntashirAkon/AppManager/blob/0152f468fc9463ee02dc2ca83f6fe4989a2c4ca5/app/src/main/java/io/github/muntashirakon/AppManager/backup/RestoreOp.java#L607-L643","documentation":"Thrown by restoreExtras when a misc/permissions restore was requested but the target application is not currently installed on the device. Misc rules (permissions and other app settings) can only be applied to an installed package, so the operation is aborted up front.","triggerScenarios":"Backup flags include restoring misc data (permissions etc.) but mIsInstalled is false — i.e. the package is not installed for mUserId when restoreExtras runs.","commonSituations":"Restoring a backup for an app that was uninstalled; restoring for a different user profile where the app isn't installed; asking for a full restore (including misc) instead of an app-only data restore.","solutions":["Install the application before running the restore, then retry the misc restore","Uncheck/misc-disable the misc restore flag in the restore options","Verify you are restoring for the correct user ID (work profile vs main user) where the app is installed","If only app data should be restored, choose a data-only restore mode"],"exampleFix":"// before\nRestoreOp.RestoreRequestFlags flags = new RestoreRequestFlags(true, true, true, true); // includes misc\nnew RestoreOp(context, backupItem, flags).runRestore();\n// after\nboolean appInstalled = isPackageInstalled(context, backupItem.getPackageName(), userId);\nRestoreOp.RestoreRequestFlags flags = new RestoreRequestFlags(true, true, true, appInstalled /* skip misc if not installed */);\nnew RestoreOp(context, backupItem, flags).runRestore();","handlingStrategy":"validation","validationCode":"try {\n    pm.getPackageInfo(packageName, 0);\n} catch (PackageManager.NameNotFoundException e) {\n    flags.skipMisc = true;\n}","typeGuard":null,"tryCatchPattern":"try {\n    restoreOp.runRestore();\n} catch (BackupException e) {\n    if (e.getMessage().contains(\"app isn't installed\")) {\n        promptInstallAppThenRetry();\n    } else throw e;\n}","preventionTips":["Always install the target app before restoring its backup","Check the correct userId/profile when restoring","Restrict restore flags to what is actually applicable"],"tags":["android","backup","restore","not-installed","precondition"],"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-23T08:17:48.524Z"}