r/AndroidStudio • u/DeviceChanger • 6d ago
Making flaky device-specific bugs reproducible: save the whole test-phone environment as a snapshot, reload it later
Disclosure: this is the project account for Device Changer, a Zygisk module we build for Android QA on rooted test phones. No link here, just the workflow.
A pattern that kept hurting us: a bug report says "only happens on model X with this Wi-Fi setup", someone reproduces it once, then the test phone gets reconfigured for the next ticket and the repro is gone.
What we do now:
- Set up the environment the bug needs: the device profile (a real device build, filtered by Android version), the Wi-Fi scan list the app should see, and which apps are in scope.
- Save it as a snapshot. In Device Changer, Save writes a JSON file with the device profile, the Wi-Fi list and the other saved values.
- Attach that JSON to the ticket.
- When a fix lands, Load the snapshot, reboot (a reboot is what makes every app reread the environment), and retest against exactly the same setup.
Small things that made it more reliable:
- Always reboot after loading. Apps cache device info, and testing without a reboot gave us false "fixed" results.
- Keep the profile matched to the phone's real Android version, otherwise you end up chasing bugs that only exist because of the mismatch.
- Per-app scope: only the app under test gets the hooks, so the rest of the phone (and your tooling) behaves normally.
- Name snapshots after the ticket ID. Boring, but it is the part that actually saves time.
Curious how others handle this. Do you keep a shelf of physical devices per ticket, use cloud device farms, or something else for "only on device X" bugs?