MuntashirAkon/AppManager · error · BackupException

Failed to backup ADB data.

Error message

Failed to backup ADB data.

What it means

backupAdb() performs an adb-style backup via BackupCompat.adbBackup and wraps any failure in this BackupException. It means the ADB-based backup stream could not be produced or written to the .ab file. The underlying Throwable is attached as cause.

Source

Thrown at app/src/main/java/io/github/muntashirakon/AppManager/backup/BackupOp.java:391

        } catch (Throwable th) {
            throw new BackupException("Failed to backup data directory at " + dir, th);
        }
    }

    @NonNull
    private Path[] backupAdb(int index) throws BackupException {
        try {
            String filePrefix = BackupUtils.getDataFilePrefix(index, ".ab");
            Path abFile = mBackupItem.getUnencryptedBackupPath().createNewFile(filePrefix, null);
            try (OutputStream os = abFile.openOutputStream()) {
                ParcelFileDescriptor fd = ParcelFileDescriptorUtil.pipeTo(os);
                BackupCompat.adbBackup(mUserId, fd, false, false, false,
                        false, false, false, false, true,
                        new String[]{mPackageName});
            }
            return new Path[]{abFile};
        } catch (Throwable th) {
            throw new BackupException("Failed to backup ADB data.", th);
        }
    }

    private void backupKeyStore() throws BackupException {  // Called only when the app has an keystore item
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
            // keystore v2 is not supported.
            Log.w(TAG, "Ignoring KeyStore backups for %s", mPackageName);
            return;
        }
        Path keyStorePath = KeyStoreUtils.getKeyStorePath(mUserId);
        try {
            Path masterKeyFile = KeyStoreUtils.getMasterKey(mUserId);
            // Master key exists, so take its checksum to verify it during the restore
            mChecksum.add(MASTER_KEY, DigestUtils.getHexDigest(mMetadata.info.checksumAlgo,
                    masterKeyFile.getContentAsString().getBytes()));
        } catch (FileNotFoundException ignore) {
        }
        // Store the KeyStore files

View on GitHub (pinned to 0152f468fc)

Solutions

  1. Check the chained cause for adbBackup failure details
  2. Verify the target app allows backup (android:allowBackup) and is not blocked by device policy
  3. Fall back to root-based data backup instead of ADB backup when available
  4. On Android 12+ consider that adb backup is deprecated and may fail for many apps

Example fix

// before
Path[] files = backupAdb(index); // throws "Failed to backup ADB data."
// after
try {
    Path[] files = backupAdb(index);
} catch (BackupException e) {
    if (!mBackupFlags.isAdBackup()) throw e; // ADB was optional
    // surface cause to user or retry with root method
}
Defensive patterns

Strategy: try-catch

Validate before calling

ApplicationInfo info = pm.getApplicationInfo(pkg, 0);
boolean adbAllowed = (info.flags & ApplicationInfo.FLAG_ALLOW_BACKUP) != 0;
if (mBackupFlags.isAdBackup() && !adbAllowed) throw new IllegalStateException("App disallows ADB backup");

Try / catch

try {
    Path[] files = backupAdb(index);
} catch (BackupException e) {
    Log.e(TAG, "adb backup failed", e.getCause());
    if (!flagsBackupCacheOnly) rethrow;
}

Prevention

When it happens

Trigger: BackupCompat.adbBackup(...) throws (backup agent unavailable, device refuses ADB backup, fd/IO errors) or writing the resulting abFile fails inside backupAdb().

Common situations: Target app sets allowBackup=false; Android 12+ deprecating adb backup; device policy blocking backup; user not confirming backup on device.

Understand the failure class

Background: "API request failed": what wrapped HTTP errors from external APIs mean and how to find the real cause — this error's family across 29 libraries.

Related errors


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