Test Backup
| Latest Update | Stable Release | Release Candidate | Beta Release | Alpha Release |
|---|---|---|---|---|
| October 21, 2026 | - | - | - | 1.0.0-alpha03 |
Declaring dependencies
To add a dependency on test backup, you must add the Google Maven repository to your project. Read Google's Maven repository for more information.
Add the dependencies for the artifacts you need in the build.gradle file for
your app or module:
Groovy
dependencies { implementation "androidx.test.backup:backup:1.0.0-alpha03" implementation "androidx.test.backup:backup-host:1.0.0-alpha03" }
Kotlin
dependencies { implementation("androidx.test.backup:backup:1.0.0-alpha03") implementation("androidx.test.backup:backup-host:1.0.0-alpha03") }
For more information about dependencies, see Add build dependencies.
Feedback
Your feedback helps make Jetpack better. Let us know if you discover new issues or have ideas for improving this library. Please take a look at the existing issues in this library before you create a new one. You can add your vote to an existing issue by clicking the star button.
See the Issue Tracker documentation for more information.
Backup
Version 1.0
Version 1.0.0-alpha02
October 07, 2026
androidx.test.backup:backup:1.0.0-alpha02 and androidx.test.backup:backup-host:1.0.0-alpha02 are released. Version 1.0.0-alpha02 contains these commits.
API Changes
- Payload keys are now documented as
BackupActionInputKeys,BackupActionOutputKeys, andBackupActionValues, replacing the constants onBackupDeviceAction. AddedBackupDeviceActionResult.success()andfailure()factories, along withisSuccessanderrorMessageaccessors. (Ibd493)
Bug Fixes
BackupRestoreController.clearAppDatanow throwsIOExceptionwhenpm cleardoes not report success, instead of continuing silently. (I61556)- Shell arguments passed to
BackupRestoreControllerfor device execution are now correctly escaped to prevent command injection and ensure file paths with spaces are handled securely. - Hardened the bundled storage actions (
PopulateStorageActionandAssertStorageAction) against silent verification passes to ensure tests strictly fail when expected data is missing. - Host-side test orchestrators now correctly honor in-band action failures reported by the device instead of ignoring them.
- Fixed an issue with database row population by percent-encoding the database
'values'wire format, preventing data corruption during payload transport. - Addressed security vulnerabilities in
androidx.test.backup:backup-hostby upgrading dependencies.
Automated Backup Restore Test Version 1.0
Version 1.0.0-alpha03
October 21, 2026
androidx.test.backup:backup:1.0.0-alpha03 and androidx.test.backup:backup-host:1.0.0-alpha03 are released. Version 1.0.0-alpha03 contains these commits.
New Features
- Simplified test setup in Android Gradle Plugin backup test suites by automatically targeting the tested app when
@BackupRestoreConfigis omitted. (I1452b) - Added support for inheriting
@BackupRestoreConfigand@Isolationsettings from an outer test class in@Nestedtest classes. (Ia45a8) - Added support for injecting
BackupRestoreControllerdirectly into test class constructors and@BeforeAllsetup methods. (I6e822, Ia2ebd) - Added support for pinning a specific device to a
@Devicerole in multi-device tests using theandroidx.test.backup.device.serial.{role}property. (I484be)
Bug Fixes
- Fixed
performBackupandperformRestoreso tests fail immediately instead of passing silently when a backup is skipped or empty, when the backup service errors out, or when a local backup archive belongs to a different app or device. (I7673d, I478ad, I0b989, I9a0ea, I79567) - Fixed tests hanging indefinitely on unresponsive devices by enforcing timeouts across backup, restore, device actions, and cleanup steps. (I10661, I9cdee, If5f92)
- Fixed
performBackupdeleting generated backup files when the test run finished, so backup archives are now kept on disk after tests exit. (I8c13f) - Fixed database test helpers (
StorageDomain.Database) to properly store and checknullvalues, overwrite existing rows when seeding test data, catch invalid table configurations early, and fail when an expected database file is missing. (Ib4767, Iddf87, I19c43, Ie8d78, I8bc18) - Fixed
SharedPreferencestest helpers to preserve data types accurately and support checking fornullor removed preferences. (I8456d9, I1d0fc2) - Fixed
runOnDeviceto handle large test payloads without crashing, pause for the debugger whenwaitForDebuggeris enabled, find the test runner in custom test APK package names, and block internal runner flags from leaking into device actions. (Ic73bd, Iede17, I1d172, I84c15) - Improved test stability and speed by sharing a single ADB connection across the test run, installing APKs only once per device, and failing clearly when an APK fails to install or launch. (I62717, Iabf75, I14e6f, I4c3da5, I54077, Iee84e)
- Fixed
fetchDeviceLogswriting empty log files, and stopped cancelled test runs from generating false failure reports. (I736c4, I7b199, Ia847e) - Cleaned up
backup-hostdependencies soadblibis available directly to callers and internal logging or test libraries no longer clash with your project's classpath. (I6e822, Iba9a4, Ib4ec9)
Version 1.0.0-alpha01
September 23, 2026
androidx.test.backup:backup:1.0.0-alpha01 and androidx.test.backup:backup-host:1.0.0-alpha01 are released. Version 1.0.0-alpha01 contains these commits.
Features of Initial Release
Initial release of the Automated Backup and Restore Testing framework for Android. This library provides an automated, end-to-end way to test that user data and account credentials safely survive device upgrades and cloud restores. Instead of relying on manual testing, developers can automate the full lifecycle: seeding app state, backing it up according to your configured rules (dataExtractionRules and fullBackupContent), wiping the app, and verifying post-restore data integrity. The framework provides two artifacts: androidx.test.backup:backup-host (which runs on the host computer to orchestrate backup, wipe, and restore passes over ADB) and androidx.test.backup:backup (which runs on the device to populate and verify app data).
BackupRestoreController: The primary host-side interface used to control backup, wipe, restore, and verification workflows for a test device. Provides convenience pipelines such asrunBackupRestoreFlowas well as fine-grained operations (performBackup,performRestore,clearAppData,fetchDeviceLogs, andrunOnDevice). Supports both Kotlin coroutines and JavaListenableFutureasynchronous execution.BackupRestoreExtension: A JUnit 5 Jupiter extension that resolves and injectsBackupRestoreControllerparameters into test methods. Manages standalone or shared ADB sessions, automatically installs tested and test APKs, dismisses device lockscreens and keyguards to unlock credential-protected storage, and enforces test sandbox isolation.BackupRestoreTestRunner: An on-deviceInstrumentationtest runner executing inside the application sandbox. Dynamically resolves and executes requestedBackupDeviceActionimplementations dispatched by host orchestrators and safely redirects large JSON result payloads to disk to prevent Binder transaction buffer limits.BackupDeviceAction: The contract for custom device-side actions executing directly within the target application sandbox during data seeding (PHASE_POPULATE) or post-restore validation (PHASE_VERIFY).StorageDomain: Strongly typed descriptors (Preference,Database,TextFile, andBinaryFile) used alongside prebuilt action helpers (PopulateStorageActionandAssertStorageAction) to automatically seed and assertSharedPreferences, SQLite databases, and raw files across both Credential Protected (CE) and Device Protected (DE) storage contexts without boilerplate.BackupTransportMode: Specifies the platform backup transport topology to simulate during test passes, includingDEVICE_TO_DEVICE(physical device migration via USB or Wi-Fi Direct),CLOUD_ENCRYPTED(cloud backup with client-side end-to-end encryption),CLOUD_UNENCRYPTED(standard cloud backup), andLOCAL(offline local filesystem backup).@Deviceand@Isolation: Host annotations for selecting connected devices matching specific serials, API levels, or multi-device roles, and configuring sandbox isolation policies between test runs (IsolationPolicy.AUTOMATICvs.IsolationPolicy.MANUAL).