{"record":{"id":"f1c71513a7edb5f7","repo":"MuntashirAkon/AppManager","slug":"failed-to-encrypt-oabconverter","errorCode":null,"errorMessage":"Failed to encrypt ","messagePattern":"Failed to encrypt ","errorType":"exception","errorClass":"BackupException","httpStatus":null,"severity":"error","filePath":"app/src/main/java/io/github/muntashirakon/AppManager/backup/convert/OABConverter.java","lineNumber":290,"sourceCode":"                mChecksum.add(CERT_PREFIX + i, checksums[i]);\n            }\n        } catch (Exception ignore) {\n        }\n        // Backup APK file\n        String sourceBackupFilePrefix = BackupUtils.getSourceFilePrefix(getExt(mDestMetadata.info.tarType));\n        Path[] sourceFiles;\n        try {\n            sourceFiles = TarUtils.create(mDestMetadata.info.tarType, baseApkFile, mBackupItem.getUnencryptedBackupPath(), sourceBackupFilePrefix,\n                            /* language=regexp */ new String[]{\".*\\\\.apk\"}, null, null, false)\n                    .toArray(new Path[0]);\n        } catch (Throwable th) {\n            throw new BackupException(\"APK files backup is requested but no APK files have been backed up.\", th);\n        }\n        // Overwrite with the new files\n        try {\n            sourceFiles = mBackupItem.encrypt(sourceFiles);\n        } catch (IOException e) {\n            throw new BackupException(\"Failed to encrypt \" + Arrays.toString(sourceFiles), e);\n        }\n        for (Path file : sourceFiles) {\n            mChecksum.add(file.getName(), DigestUtils.getHexDigest(mDestMetadata.info.checksumAlgo, file));\n        }\n    }\n\n    private void backupData() throws BackupException {\n        List<Path> dataFiles = new ArrayList<>(2);\n        if (mDestMetadata.info.flags.backupInternalData()) {\n            try {\n                dataFiles.add(mBackupLocation.findFile(CryptoUtils.getAppropriateFilename(mPackageName + \".zip\",\n                        mSourceCryptoMode)));\n            } catch (FileNotFoundException e) {\n                throw new BackupException(\"Could not get internal data backup.\", e);\n            }\n        }\n        if (mDestMetadata.info.flags.backupExternalData()) {\n            try {","sourceCodeStart":272,"sourceCodeEnd":308,"githubUrl":"https://github.com/MuntashirAkon/AppManager/blob/0152f468fc9463ee02dc2ca83f6fe4989a2c4ca5/app/src/main/java/io/github/muntashirakon/AppManager/backup/convert/OABConverter.java#L272-L308","documentation":"After tar creation, the freshly written APK source files are encrypted via mBackupItem.encrypt(sourceFiles). If that encryption throws IOException (stream failure, disk full, key issues), it is wrapped into this BackupException whose message includes the file list being encrypted. The unencrypted tar may have been produced but the final encrypted backup could not be completed.","triggerScenarios":"backupApkFile() calls mBackupItem.encrypt(sourceFiles) and it throws IOException at OABConverter.java:290, where sourceFiles are the .apk entries just created by TarUtils.create().","commonSituations":"Encryption enabled in backup settings but crypto provider/key unavailable; storage full mid-encrypt; the files listed were moved/deleted between tar creation and encryption; backup item path permissions changed.","solutions":["Check available disk space on the backup destination and free space if needed.","Verify the encryption key/crypto provider is correctly configured (or disable encryption in backup settings to produce a plaintext backup).","Confirm the unencrypted backup path files still exist and are readable at encryption time.","Retry the conversion; inspect the IOException cause for the underlying stream error."],"exampleFix":"// before: encryption on but no key configured\n// BackupFlags flags = new BackupFlags(BackupFlags.BACKUP_MULTIPLE | BackupFlags.BACKUP_APK_FILES);\n// after: either configure crypto or drop the encryption expectation\n// flags.removeFlag(BackupFlags.BACKUP_ENCRYPT); // produce unencrypted backup instead","handlingStrategy":"try-catch","validationCode":"// Ensure encryption is configured if requested\nif (flags.has(BackupFlags.BACKUP_ENCRYPT) && cryptoProvider == null) {\n    throw new IllegalStateException(\"Encryption requested but no crypto provider configured\");\n}","typeGuard":null,"tryCatchPattern":"try {\n    converter.convert(...);\n} catch (BackupException e) {\n    if (e.getMessage().startsWith(\"Failed to encrypt\")) {\n        Log.e(TAG, \"Encrypt step failed; check key setup and disk space\", e.getCause());\n    }\n}","preventionTips":["Configure the crypto provider/keys before running conversions with encryption enabled.","Monitor free space on the backup destination — encryption doubles transient usage.","Avoid concurrent jobs writing to the same backup item path."],"tags":["android","backup","encryption","io","apk"],"backgroundTag":"file-write-failed","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"}