Skip to Content
Spawndroid

Mock location

Override the device GPS with fixed coordinates for location-aware tests.

Every Spawndroid device can report a fixed GPS position. Spawndroid registers Android test location providers (gps and network), so apps that read location see the coordinates you set instead of the container's own. The container has no radio, so without a fix there is no location.

Prerequisites

  • A live session.
  • An API key with upload scope, or access to the console.

From the console

Open a session and switch to the Network tab. Under Mock location, pick a preset city, or enter a latitude and longitude and select Apply. The device keeps reporting the fix until you select Clear or the session ends.

From the API

Set a fix with a key that has upload scope:

curl -X POST "https://app.spawndroid.io/api/sessions/$SESSION_ID/location" \
  -H "Authorization: Bearer $SPAWNDROID_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"location":{"latitude":51.5074,"longitude":-0.1278,"accuracy":25}}'

accuracy is optional and measured in meters. To clear the fix and return the device to its own location sources, send {"location":null}.

Set a fix when starting a session

Pass location when you create a per-run session, so the device boots with the fix already applied:

curl -X POST "https://app.spawndroid.io/api/v1/sessions" \
  -H "Authorization: Bearer $SPAWNDROID_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"artifactId":"my-app","location":{"latitude":35.6762,"longitude":139.6503}}'

artifactId is required. location is optional and accepts accuracy as well.

Behavior and limits

  • The fix is applied when the device boots and can be changed at any time while the session is live.
  • Spawndroid overrides both the gps and network providers, so apps that read fused or network location see the fix too.
  • Locations are flagged as mock, exactly like an emulator override. Apps that explicitly reject mock locations ignore them.
  • The override lives inside the session's isolation boundary and never reaches another session.

Next steps

Was this page helpful?

On this page