Play Games Saved Games: A Merge That Never Goes Backwards
By Nesim Razon, independent mobile developer · 2026-12-03
Saved Games looks simple: open a snapshot, read it, write it. The hard part is what happens when two phones have played different amounts. I keep game progress as a small piece of text and merge it with rules that can only move forward. This post explains the format, the merge rules, when the sync runs, and the setup mistakes that made cloud saving silently do nothing on a fresh install.

One small text snapshot
Play Games Saved Games stores a named snapshot, which is just bytes with a description. For my small games the whole progress fits in one snapshot called progress. I do not store a database or a screenshot, only a few lines of text. Each line is a key, a type letter and a value, such as a counter, a flag or a set of ids, and settings or half-finished rounds are left out on purpose.
Keeping it this small has two benefits. It is cheap to read and write on every sync, and it is easy to reason about. If a value is not in the text, the sync cannot break it.
When I open the snapshot I ask for the policy that keeps the most recently modified copy if the cloud ever finds two versions. That only decides which bytes win at the storage level. The real decision about what the player keeps happens in my own code, one step later.
The sync is read, merge, write
A sync opens the snapshot, reads the remote text, hands it to a merge function and writes back whatever that function returns. If the function returns nothing, the snapshot is discarded and nothing is written. The merge runs on the main thread, so it may update the screen state directly, and the file work itself runs on a background dispatcher.
The merge function never trusts either side. It takes the local values and the remote values and produces a third set that is at least as good as both. Because the result goes back to the cloud, the next phone to sync starts from a state that already contains everything this phone knew.
If the player is not signed in to Play Games, the sync simply returns. There is no error message and no dialog, which is what you want in a game, and also what makes problems hard to see. More on that below.
Four rules that cannot lose progress
- MAX for counters and records: games played, best scores and similar numbers keep the larger value.
- MIN for best times: the smaller positive value wins, and a zero means no time yet and never beats a real one.
- OR for flags: a tutorial seen or a level completed on either phone stays true.
- UNION for sets: items collected on either phone are all kept, so two phones that found different things end up with both.
Streaks need more care. A streak is a pair of values, the last day played and the length. Merging them separately could produce a last day from one phone and a length from the other. So I treat them as a pair: the side with the later last day supplies both numbers, and if the days are equal, the larger length wins. A test named streakPairComesFromNewestDay covers exactly this, and another one, neverGoesBackwards, checks that every other rule keeps the larger or combined result.
Applying the result without surprising the player
On the phone, the merged result is written to local storage only if it differs from what is already there. If nothing changed, nothing is rewritten and the screen is not disturbed. When something did change, a callback tells the interface to read its state again.
In one game I apply the cloud copy only when it is clearly ahead, meaning it records more plays or a later gift day than the phone, and only while the player is in the lobby and not in the middle of a spin. A state change during play would be a worse experience than waiting a few seconds.
Because the merge can only increase things, a reinstall or a second device can never turn a good save into a worse one. The worst case is that an old device catches up the next time it syncs.
When the sync runs
I sync when the game comes to the foreground and when the player returns to a quiet moment, such as the lobby, after progress has changed. A sync that happened less than twenty seconds ago is skipped, unless the action is a forced one such as a reset, so that a player who flicks between screens does not cause a burst of requests.
In debug builds the cloud save is switched off entirely. The Play Games credentials are tied to the store package name and its signing key, so a debug build with a different package name cannot sign in anyway, and an attempt would only add noise to the logs.
Traps on the first real test
On the first reinstall test of a new game, the balance came back as a fresh start. The cloud save did nothing. Nothing appeared in the logs from my own code, because a failed sign-in returns silently. The system log, however, had a clear line: DEVELOPER_ERROR, with the certificate fingerprint of the installed app printed under it.
The fingerprint was not the one I had registered. The Play Console shows more than one app signing key, and I had copied the one listed first, not the one the installed app actually used. Registering a second OAuth client with the fingerprint from the log fixed it. The lesson: take the fingerprint from the device log, not from memory of which key you think is in use.
Another trap is the game settings status. While the Play Games project is still a draft, only listed testers can sign in. Publishing the game settings in the Play Console takes effect immediately and does not wait for the app to go to production.
When it finally worked, the order looked odd at first: the game opened with the starting balance, gave the daily gift, and a few seconds later the saved balance arrived. That is normal, because reading the cloud is asynchronous and the merge keeps the larger values, so the gift is not added twice.
A short checklist
- Keep the snapshot to a few lines of text and exclude settings and half-finished rounds.
- Choose a merge rule per key: MAX, MIN, OR, UNION, and treat paired values together.
- Write unit tests for the merge, including a streak pair and a case where each side leads in a different field.
- Log the sign-in result somewhere you can see it, or a silent failure will look like a working feature.
- On the first device test, read the fingerprint printed by DEVELOPER_ERROR and compare it with the one in the OAuth client.
Frequently asked questions
What is a Saved Games snapshot?
A named blob of bytes with a description that Play Games stores for the signed-in player, readable on any of their devices.
Why merge instead of letting the newest save win?
The newest copy can be the one with less progress, for example after a reinstall. A merge keeps the larger values from both.
Why does a failed sign-in show no error?
The sync simply returns when the player is not authenticated, so you must log the result yourself to see it.
Does publishing the game settings wait for the app release?
No. Publishing the Play Games settings applies immediately and is separate from the app's production release.
Why did the restored balance arrive a few seconds late?
Reading the cloud is asynchronous, so the game shows local state first and applies the merged result when it arrives.
More from the blog
- What Stays Platform-Specific in a Kotlin Multiplatform App
- Declaring a Walking Game's Health Data in Play Console
- Blender From the Command Line: Pale Colours and Boolean Order
- From Blender Renders to Compose: Sprite Atlas and Layers
- A Four-Language Static Site in Python: hreflang and Sitemap
- A Preflight Script for iOS Builds: Save Cloud Mac Minutes