How to Test Location Features on a Real Android Device
Emulators are great for a single coordinate. Real bugs show up with real hardware, real movement and imperfect GPS. This is how I reproduce all three without leaving my desk.
Why the emulator isn't enough
The Android emulator can set a location from its extended controls, or with
adb emu geo fix. That covers "is the user in this city?". It misses a lot of
what breaks in production:
- OEM battery optimizations that pause location updates on real phones.
- Movement over time: entering and leaving geofences, speed-based activity detection, trip start and stop logic.
- Noisy fixes: accuracy that jumps from 5 m to 40 m, positions that drift while the phone is sitting still.
- Other apps on the device that react to your location, such as a companion app or a partner SDK.
A mock location app on a physical device fills that gap. It uses Android's
official test provider API, so every app that asks LocationManager or the
fused location provider gets the same simulated position.
1. Set up a mock location provider
- Turn on Developer Options: Settings, About phone, tap Build number seven times.
- Install a mock location app. I built GentleSquid for this, and the rest of this guide uses it.
- Developer options, Select mock location app, choose it.
In your own code, Location.isMock() (API 31+) or isFromMockProvider() on
older versions tells you a fix is simulated. Make sure production logic that
rejects mock locations sits behind a flag you can turn off in debug builds.
2. Test a single coordinate
Search a place or tap the map, then start mocking. Save the coordinates you test often (the office, a geofence edge, a store in another region) as favorites. Good for:
- Region-locked content, pricing, currency and language defaults.
- "Nearby" lists and distance sorting.
- Geofence edges. Put a pin just inside and just outside the radius.
3. Test movement with routes and GPX replay
Most location bugs are about change. Add waypoints to build a route, snap it to roads, and play it back at walking, cycling, driving or a custom speed, looping if you need a soak test. Better still, import a GPX track recorded on a real trip (most fitness apps and GPS loggers export GPX) and replay it exactly.
What to check while a route plays:
- Geofence enter, dwell and exit events fire once, in order.
- Trip detection starts and ends where you expect.
- Distance, pace and ETA calculations match the route.
- Background delivery keeps working with the screen off for 10+ minutes.
Save a route, its movement mode and looping as a scenario so the whole team reruns the identical test after each build.
4. Add realistic GPS noise
A perfect fix every second hides bugs. Real receivers drift slowly and report changing accuracy. GentleSquid models noise that is correlated over time instead of random jumps, and varies the reported accuracy the way hardware does. Tune jitter, reported accuracy, update interval, bearing and altitude to reproduce:
- A phone sitting still that appears to wander 10 to 20 m (a false "trip started").
- Low-accuracy fixes you should filter out before saving a track.
- Slow update intervals that make speed and ETA estimates jumpy.
5. Steer live for exploratory testing
For ad-hoc checks, switch on the joystick and drive the location around by hand while watching your app react. It is the fastest way to poke at a geofence boundary from different directions.
A quick location test checklist
- Permission states: precise, approximate, "only this time", denied, revoked while running.
- A static coordinate inside and outside every geofence.
- A replayed real-world GPX track at a realistic speed.
- The same track with high jitter and poor accuracy.
- Screen off, app in background, battery saver on.
- Mock location turned off mid-session, so the app recovers to the real provider.
Why I made it a paid tool
GentleSquid costs $4.99 once on Google Play. It has no ads covering your test screens, no analytics SDK adding its own traffic to your network captures, and no account. Your test routes stay on the device.