{"record":{"id":"9f205182eef2c906","repo":"MuntashirAkon/AppManager","slug":"failed-to-encrypt-checksums-txt-sbconverter","errorCode":null,"errorMessage":"Failed to encrypt checksums.txt","messagePattern":"Failed to encrypt checksums\\.txt","errorType":"exception","errorClass":"BackupException","httpStatus":null,"severity":"error","filePath":"app/src/main/java/io/github/muntashirakon/AppManager/backup/convert/SBConverter.java","lineNumber":141,"sourceCode":"            }\n            if (mDestMetadata.info.flags.backupData()) {\n                backupData();\n            }\n            // Write modified metadata\n            try {\n                Map<String, String> filenameChecksumMap = MetadataManager.writeMetadata(mDestMetadata, mBackupItem);\n                for (Map.Entry<String, String> filenameChecksumPair : filenameChecksumMap.entrySet()) {\n                    mChecksum.add(filenameChecksumPair.getKey(), filenameChecksumPair.getValue());\n                }\n            } catch (IOException e) {\n                throw new BackupException(\"Failed to write metadata.\");\n            }\n            mChecksum.close();\n            // Encrypt checksum\n            try {\n                mBackupItem.encrypt(new Path[]{mChecksum.getFile()});\n            } catch (IOException e) {\n                throw new BackupException(\"Failed to encrypt checksums.txt\");\n            }\n            // Replace current backup\n            try {\n                mBackupItem.commit();\n            } catch (IOException e) {\n                throw new BackupException(\"Could not finalise backup.\", e);\n            }\n            backupSuccess = true;\n        } catch (BackupException e) {\n            throw e;\n        } catch (Throwable th) {\n            throw new BackupException(\"Unknown error occurred.\", th);\n        } finally {\n            mBackupItem.cleanup();\n            mCachedApk.requireParent().delete();\n            if (backupSuccess) {\n                BackupUtils.putBackupToDbAndBroadcast(ContextUtils.getContext(), mDestMetadata);\n            }","sourceCodeStart":123,"sourceCodeEnd":159,"githubUrl":"https://github.com/MuntashirAkon/AppManager/blob/0152f468fc9463ee02dc2ca83f6fe4989a2c4ca5/app/src/main/java/io/github/muntashirakon/AppManager/backup/convert/SBConverter.java#L123-L159","documentation":"SBConverter.convert throws BackupException('Failed to encrypt checksums.txt') when mBackupItem.encrypt on the checksum file throws IOException. The checksums.txt must be encrypted to match the backup's crypto settings before commit; failure aborts conversion. The cause IOException is dropped here as well.","triggerScenarios":"Encrypting the checksum file fails: crypto provider/key error surfaced as IOException, missing source checksum file, or destination I/O failure during encryption write.","commonSituations":"Destination crypto key/password mismatch; storage full while writing encrypted output; checksum file deleted or closed incorrectly before encryption.","solutions":["Verify the destination crypto key/password is correct","Ensure mChecksum was closed successfully and its file still exists before encrypt","Check free space in the backup directory","Check logcat for the original IOException since the BackupException omits the cause"],"exampleFix":"// before\nthrow new BackupException(\"Failed to encrypt checksums.txt\");\n// after\nthrow new BackupException(\"Failed to encrypt checksums.txt\", e);","handlingStrategy":"try-catch","validationCode":"File checksumFile = new File(mChecksum.getFile().getUri().getPath());\nif (!checksumFile.exists() || checksumFile.length() == 0) {\n    throw new IOException(\"checksums.txt missing or empty before encryption\");\n}","typeGuard":null,"tryCatchPattern":"try {\n    converter.convert(...);\n} catch (BackupException e) {\n    if (\"Failed to encrypt checksums.txt\".equals(e.getMessage())) {\n        // verify crypto key and destination storage, then retry\n    }\n}","preventionTips":["Close the checksum writer before encrypting its file","Confirm crypto key/password correctness","Ensure sufficient free space for the encrypted output"],"tags":["android","backup","encryption","checksum"],"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-14T16:17:12.679Z"}