{"record":{"id":"154896edb8d47e3a","repo":"MuntashirAkon/AppManager","slug":"failed-to-create-checksum-file","errorCode":null,"errorMessage":"Failed to create checksum file.","messagePattern":"Failed to create checksum file\\.","errorType":"exception","errorClass":"BackupException","httpStatus":null,"severity":"error","filePath":"app/src/main/java/io/github/muntashirakon/AppManager/backup/BackupOp.java","lineNumber":139,"sourceCode":"                    PackageManager.GET_META_DATA | GET_SIGNING_CERTIFICATES | PackageManager.GET_PERMISSIONS\n                            | PackageManagerCompat.MATCH_STATIC_SHARED_AND_SDK_LIBRARIES, userId);\n            Objects.requireNonNull(mPackageInfo);\n            mApplicationInfo = Objects.requireNonNull(mPackageInfo.applicationInfo);\n            // Override existing metadata\n            mMetadata = setupMetadataAndCrypto();\n        } catch (Throwable e) {\n            mBackupItem.cleanup();\n            throw new BackupException(\"Failed to setup metadata.\", e);\n        }\n        try {\n            mChecksum = mBackupItem.getChecksum();\n            String[] certChecksums = PackageUtils.getSigningCertChecksums(mMetadata.info.checksumAlgo, mPackageInfo, false);\n            for (int i = 0; i < certChecksums.length; ++i) {\n                mChecksum.add(CERT_PREFIX + i, certChecksums[i]);\n            }\n        } catch (Throwable e) {\n            mBackupItem.cleanup();\n            throw new BackupException(\"Failed to create checksum file.\", e);\n        }\n    }\n\n    @Override\n    public void close() {\n        mBackupItem.cleanup();\n    }\n\n    @NonNull\n    public BackupMetadataV5 getMetadata() {\n        return mMetadata;\n    }\n\n    void runBackup(@Nullable ProgressHandler progressHandler) throws BackupException {\n        try {\n            // Fail backup if the app has items in Android KeyStore and backup isn't enabled\n            if (mBackupFlags.backupData() && mMetadata.metadata.keyStore && !Prefs.BackupRestore.backupAppsWithKeyStore()) {\n                throw new BackupException(\"The app has keystore items and KeyStore backup isn't enabled.\");","sourceCodeStart":121,"sourceCodeEnd":157,"githubUrl":"https://github.com/MuntashirAkon/AppManager/blob/0152f468fc9463ee02dc2ca83f6fe4989a2c4ca5/app/src/main/java/io/github/muntashirakon/AppManager/backup/BackupOp.java#L121-L157","documentation":"BackupOp wraps any failure while generating and writing the backup checksum file (checksums.txt) in a BackupException with this message, chaining the original cause. The checksum file records digests of all backed-up artifacts (APKs, data, metadata, signing certs) under the metadata's checksum algorithm. Because the checksum is written late in the backup pipeline, this indicates the backup largely succeeded but could not be finalized.","triggerScenarios":"An exception (any Throwable) is thrown inside the checksum-building block: PackageUtils.getSigningCertChecksums fails, Checksum add() fails writing to the file, or the checksum file cannot be created/flushed on the backup storage.","commonSituations":"Storage full or I/O errors on the backup destination (SD card, external storage, SAF-backed path); unsupported or misconfigured checksum algorithm in metadata; failure to compute signing cert checksums for apps with unusual signing schemes.","solutions":["Check free space and writability of the backup destination directory.","Verify the checksum algorithm recorded in backup metadata is one supported by DigestUtils (e.g. MD5, SHA-1, SHA-256).","Inspect the chained cause ('Caused by') of the BackupException for the real I/O or crypto failure.","Retry the backup after clearing the incomplete backup directory (BackupOp cleans up via mBackupItem.cleanup())."],"exampleFix":"// before\nString[] certChecksums = PackageUtils.getSigningCertChecksums(mMetadata.info.checksumAlgo, mPackageInfo, false);\n// after\nif (!DigestUtils.isSupportedAlgo(mMetadata.info.checksumAlgo)) {\n    mMetadata.info.checksumAlgo = \"SHA-256\";\n}\nString[] certChecksums = PackageUtils.getSigningCertChecksums(mMetadata.info.checksumAlgo, mPackageInfo, false);","handlingStrategy":"try-catch","validationCode":"File dest = backupDir; if (!dest.canWrite() || dest.getUsableSpace() < 50*1024*1024) throw new IOException(\"Destination unwritable or low on space\");","typeGuard":"boolean isSupportedAlgo(String algo) { return algo != null && Arrays.asList(\"MD5\",\"SHA-1\",\"SHA-256\",\"SHA-512\").contains(algo); }","tryCatchPattern":"try {\n    new BackupOp(context, packageInfo, flags).runBackup(progress);\n} catch (BackupException e) {\n    Log.e(TAG, \"checksum stage failed\", e.getCause());\n    cleanupIncompleteBackup(backupDir);\n}","preventionTips":["Verify destination free space before starting a backup.","Stick to standard checksum algorithms (SHA-256) in metadata.","Always read BackupException.getCause() — the message is generic, the cause is specific.","Let BackupOp.cleanup() remove partial state before retrying."],"tags":["android","backup","checksum","io"],"backgroundTag":"checksum-mismatch","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"}