{"record":{"id":"35114908b26b08b8","repo":"MuntashirAkon/AppManager","slug":"adb-restore-is-requested-but-there-are-no-ab-files","errorCode":null,"errorMessage":"ADB restore is requested but there are no .ab files.","messagePattern":"ADB restore is requested but there are no \\.ab files\\.","errorType":"exception","errorClass":"BackupException","httpStatus":null,"severity":"error","filePath":"app/src/main/java/io/github/muntashirakon/AppManager/backup/RestoreOp.java","lineNumber":606,"sourceCode":"        } catch (Throwable th) {\n            throw new BackupException(\"Failed to restore data files for index \" + index + \".\", th);\n        }\n        // Restore UID and GID\n        if (!Runner.runCommand(String.format(Locale.ROOT, \"chown -R %d:%d \\\"%s\\\"\", uidGidPair.uid, uidGidPair.gid, dataSourceFile.getFilePath())).isSuccessful()) {\n            if (!Utils.isRoboUnitTest()) {\n                throw new BackupException(\"Failed to restore ownership info for index \" + index + \".\");\n            } // else Don't care about permissions\n        }\n        // Restore context\n        if (!dataDirectoryInfo.isExternal()) {\n            Runner.runCommand(new String[]{\"restorecon\", \"-R\", dataSourceFile.getFilePath()});\n        }\n    }\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) {","sourceCodeStart":588,"sourceCodeEnd":624,"githubUrl":"https://github.com/MuntashirAkon/AppManager/blob/0152f468fc9463ee02dc2ca83f6fe4989a2c4ca5/app/src/main/java/io/github/muntashirakon/AppManager/backup/RestoreOp.java#L588-L624","documentation":"Thrown by restoreAdb when an ADB-based backup restore was requested but the backup directory does not contain exactly one .ab (Android backup) file for the given index. The ADB restore path expects a single adb archive; an empty or malformed dataFiles array means the required archive is absent.","triggerScenarios":"Calling restoreAdb when mBackupItem.getDataFiles(index) returns an array whose length != 1 — i.e. zero .ab files (or more than one) present in the backup for that index.","commonSituations":"Restoring a backup whose mode is ADB but the .ab file was deleted, not copied along with the rest of the backup folder, or the backup was actually created with a different mode (files/tar) so no .ab archive exists.","solutions":["Verify the backup directory contains exactly one .ab file for the requested index before starting the restore","Re-copy the complete backup folder from its original location including all archives","Check Metadata.json / backup mode: if the backup was created in files mode, use the files restore path instead of ADB","Re-create the backup with ADB mode if the archive is genuinely lost"],"exampleFix":"// before\nPath[] dataFiles = mBackupItem.getDataFiles(index);\n// assume it's fine\n// after\nPath[] dataFiles = mBackupItem.getDataFiles(index);\nif (dataFiles.length != 1 || !dataFiles[0].getName().endsWith(\".ab\")) {\n    throw new IllegalStateException(\"Backup folder is missing the required .ab archive; restore aborted before BackupException\");\n}","handlingStrategy":"validation","validationCode":"Path[] files = mBackupItem.getDataFiles(index);\nlong abCount = Arrays.stream(files).filter(f -> f.getName().endsWith(\".ab\")).count();\nif (abCount != 1) throw new IllegalStateException(\"Expected exactly one .ab file, found \" + abCount);","typeGuard":null,"tryCatchPattern":"try {\n    restoreOp.runRestore();\n} catch (BackupException e) {\n    if (e.getMessage().contains(\"no .ab files\")) {\n        showUserMessage(\"Backup archive (.ab) is missing; cannot ADB-restore this backup.\");\n    } else throw e;\n}","preventionTips":["Always copy the whole backup directory, not just selected files","Cross-check the backup mode in metadata before choosing the restore path","Validate backup contents (checksums/file listing) before starting a restore"],"tags":["android","backup","adb","missing-file"],"backgroundTag":"file-not-found","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"}