feat(android): exclude SDK state from Auto Backup via config plugin#4
Merged
Conversation
The MotionTag Android guide requires excluding the SDK's SharedPreferences file (motiontag_tracker.xml, verified against the tracker AAR) from Android Auto Backup — a backup restored on reinstall or device transfer would otherwise resurrect stale SDK state. The new withAndroidBackupRules plugin runs as a finalized mod so it sees backup rules set by any other plugin regardless of app.json ordering: - no existing rules: creates MotionTag-owned exclude-only rule files and references them from the manifest - existing rules (e.g. expo-secure-store): merges the exclude into an app-level resource override with the same name, leaving the manifest reference (and the other plugin's idempotency check) untouched - allowBackup="false" or rules it cannot edit: skips, warning with manual instructions in the latter case Both rule formats are covered: full-backup-content (Android <= 11) and data-extraction-rules cloud-backup + device-transfer (Android 12+). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1d649c2 to
171be3c
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
The MotionTag Android guide requires excluding the SDK's SharedPreferences file from Android Auto Backup — a backup restored on reinstall or device transfer would otherwise resurrect stale SDK state (device registration, tracking state) and confuse the backend.
The prefs file name
motiontag_tracker.xmlwas verified against thede.motiontag:tracker:7.2.5AAR (getSharedPreferences("motiontag_tracker", ...)).What
New
plugin/withAndroidBackupRules.js, registered in the config plugin chain. It runs as a finalized mod so it sees backup rules set by any other plugin regardless ofapp.jsonplugin ordering:allowBackup="false"Both rule formats are covered:
full-backup-content(Android ≤ 11) anddata-extraction-rulescloud-backup + device-transfer (Android 12+).Also documents the manual exclusion for bare-RN hosts in the README.
Verification
Against the example app (which uses expo-secure-store):
expo prebuild(with and without--clean) produces no duplicate excludes🤖 Generated with Claude Code