{"record":{"id":"5bbf68e613d55adb","repo":"MuntashirAkon/AppManager","slug":"failed-to-restore-adb-data","errorCode":null,"errorMessage":"Failed to restore ADB data","messagePattern":"Failed to restore ADB data","errorType":"exception","errorClass":"BackupException","httpStatus":null,"severity":"error","filePath":"app/src/main/java/io/github/muntashirakon/AppManager/backup/RestoreOp.java","lineNumber":619,"sourceCode":"    }\n\n    private void restoreAdb(int index) throws BackupException {\n        Path[] dataFiles = mBackupItem.getDataFiles(index);\n        if (dataFiles.length != 1) {\n            throw new BackupException(\"ADB restore is requested but there are no .ab files.\");\n        }\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) {","sourceCodeStart":601,"sourceCodeEnd":637,"githubUrl":"https://github.com/MuntashirAkon/AppManager/blob/0152f468fc9463ee02dc2ca83f6fe4989a2c4ca5/app/src/main/java/io/github/muntashirakon/AppManager/backup/RestoreOp.java#L601-L637","documentation":"Thrown by restoreAdb when piping the decrypted archive into BackupCompat.adbRestore via a ParcelFileDescriptor fails, for any Throwable. This is the actual hand-off of the archive to Android's adb backup restore mechanism; any failure there (I/O, binder, service failure) is wrapped in this message.","triggerScenarios":"BackupCompat.adbRestore(mUserId, fd) throws — e.g. pipeFrom fails on the InputStream, the binder transaction fails, the system's restore service rejects the archive, or the decrypted stream is empty/invalid.","commonSituations":"Android version incompatibility (adb backup deprecated/restricted in newer Android); corrupted decrypted archive; device policy blocking backup restore; insufficient memory opening the stream.","solutions":["Verify the decrypted archive is valid (test with `ab restore` tooling or re-create the backup)","Try restoring via ADB from a PC (`adb restore file.ab`) to get a clearer system-level error","Check the Android version: on Android 12+ adb backup is heavily restricted; prefer files-mode backups","Re-create the backup on the target device with AppManager's native (files) backup mode instead of ADB mode"],"exampleFix":"// before\ntry (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// after\ntry (InputStream is = dataFiles[0].openInputStream()) {\n    ParcelFileDescriptor fd = ParcelFileDescriptorUtil.pipeFrom(is);\n    BackupCompat.adbRestore(mUserId, fd);\n} catch (Throwable th) {\n    Log.e(TAG, \"adbRestore failed; suggest files-mode backup instead\", th);\n    throw new BackupException(\"Failed to restore ADB data\", th);\n}","handlingStrategy":"try-catch","validationCode":"if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {\n    warn(\"adb backup restore is unreliable on Android 12+; use files-mode backup\");\n}","typeGuard":null,"tryCatchPattern":"try {\n    restoreOp.runRestore();\n} catch (BackupException e) {\n    if (\"Failed to restore ADB data\".equals(e.getMessage())) {\n        Log.e(TAG, \"ADB restore failed\", e.getCause());\n        fallbackToFilesRestoreOrAbort();\n    } else throw e;\n}","preventionTips":["Prefer files/tar backup mode over ADB mode on modern Android","Validate the .ab archive before piping it into the restore","Ensure the device has free memory and no policy blocking backup operations","Keep AppManager updated for BackupCompat compatibility fixes"],"tags":["android","backup","adb","restore","binder"],"backgroundTag":"upstream-api-error","analyzedSha":"0152f468fc9463ee02dc2ca83f6fe4989a2c4ca5","analyzedAt":"2026-09-12T14:03:37.243Z","contentChangedAt":"2026-09-12T14:03:37.243Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}