MuntashirAkon/AppManager · error · BackupException

Failed to get crypto

Error message

Failed to get crypto 

What it means

TBConverter.convert() wraps CryptoException from ConvertUtils.getV5Metadata() (which computes the destination crypto/keystore parameters for the converted backup) into a BackupException. It means the metadata conversion could not obtain the cryptographic settings (key alias, cipher, keystore access) needed to build the v5 destination metadata.

Source

Thrown at app/src/main/java/io/github/muntashirakon/AppManager/backup/convert/TBConverter.java:124

            throw new BackupException("Could not read package name.");
        }
        // Source metadata
        mSourceMetadata = readPropFile();
        // Simulate a backup creation
        try {
            mBackupItem = BackupItems.createBackupItemGracefully(mUserId, "TB", mPackageName);
        } catch (IOException e) {
            throw new BackupException("Could not get backup files", e);
        }
        boolean backupSuccess = false;
        try {
            try {
                // Destination metadata
                mDestMetadata = ConvertUtils.getV5Metadata(mSourceMetadata, mBackupItem);
                // Destination APK will be renamed
                mDestMetadata.metadata.apkName = "base.apk";
            } catch (CryptoException e) {
                throw new BackupException("Failed to get crypto " + mDestMetadata.info.crypto, e);
            }
            try {
                mChecksum = mBackupItem.getChecksum();
            } catch (IOException e) {
                throw new BackupException("Failed to create checksum file.", e);
            }
            // Backup icon
            backupIcon();
            if (mDestMetadata.info.flags.backupApkFiles()) {
                backupApkFile();
            }
            if (mDestMetadata.info.flags.backupData()) {
                backupData();
            }
            // Write modified metadata
            try {
                Map<String, String> filenameChecksumMap = MetadataManager.writeMetadata(mDestMetadata, mBackupItem);
                for (Map.Entry<String, String> filenameChecksumPair : filenameChecksumMap.entrySet()) {

View on GitHub (pinned to 0152f468fc)

Solutions

  1. Verify the BackupItem's crypto settings (keystore path, key alias, passwords, cipher mode) are valid before calling convert().
  2. Re-create or re-select the encryption key/keystore, or set the backup to unencrypted if crypto is not needed.
  3. Inspect the wrapped CryptoException cause for the underlying keystore/algorithm error and fix it accordingly.

Example fix

// before
mBackupItem.setCryptoAlgo(CryptoUtils.CRYPTO_AES_GCM); // with missing/invalid keystore
convert();
// after
if (CryptoUtils.getKeystore().isPresent()) {
    mBackupItem.setCryptoAlgo(CryptoUtils.CRYPTO_AES_GCM);
    convert();
} else {
    throw new IllegalStateException("Select or create a keystore key before converting to encrypted backup");
}
Defensive patterns

Strategy: validation

Validate before calling

// Kotlin/Java pseudo-check before convert()
if (mBackupItem.isEncrypted()) {
    if (!CryptoUtils.hasValidKey(mDestMetadata.crypto.keyAlias)) {
        throw new IllegalStateException("Configure a valid keystore key before converting to encrypted backup");
    }
}

Type guard

fun CryptoInfo?.isValid(): Boolean = this != null && !keyAlias.isNullOrBlank() && algo != null

Try / catch

try {
    converter.convert();
} catch (BackupException e) {
    if (e.getCause() instanceof CryptoException ce) {
        Log.e(TAG, "Crypto setup failed: " + ce.getMessage());
        promptUserToSelectKey();
    }
}

Prevention

When it happens

Trigger: Calling convert() on a source backup whose destination metadata requires crypto info that cannot be resolved: ConvertUtils.getV5Metadata(mSourceMetadata, mBackupItem) throws CryptoException because the destination backup item's crypto settings (keystore/key/algorithm) are unavailable or invalid.

Common situations: Converting a backup to the encrypted (TAR+GZIP+CRYPTO) format without a valid keystore or a key selected; keystore file missing/corrupted; a keystore password or key alias mismatch; the destination metadata references a crypto mode unsupported by the configured encryption algorithm.

Related errors


AI-assisted analysis of MuntashirAkon/AppManager@0152f468fc (2026-09-12). Data as JSON: /api/errors/f428c4f445b0a240. Report an issue: GitHub.