Simulating Mock GPS Locations on Android with Developer Options and ADB

13 min read Step‑by‑step guide to enable mock GPS on Android, feed custom coordinates via ADB, and troubleshoot common issues without rooting your device. October 11, 2026 12:30 How to Simulate Mock GPS Locations on Android with Developer Options and ADB

Why Simulate GPS Locations?

Developers, testers, and privacy‑conscious users often need to make an Android device think it is somewhere else. Common scenarios include:

  • Testing location‑based apps before they launch globally.
  • Demonstrating a feature to a client without traveling.
  • Temporarily bypassing geo‑restricted services for legitimate purposes.

Android’s built‑in Mock location capability lets you feed arbitrary coordinates to the system. When combined with adb, you can script precise movements, repeatable test cases, or one‑off location swaps—all without rooting.

Note: Mock locations affect all apps that request location data. Some apps (e.g., banking, payment, or certain games) may refuse to run if they detect mock locations. Use this feature responsibly and revert to real GPS when finished.

Before You Start

  • Device requirements: Android 6.0 (Marshmallow) or newer. The steps are similar on newer versions, but menu wording may differ slightly.
  • Computer setup: A Windows, macOS, or Linux PC with Android Platform‑Tools (ADB) installed and added to your PATH.
  • USB debugging enabled: Settings > About phone > tap Build number seven times, then Settings > System > Developer options > USB debugging.
  • Battery: Keep the phone charged above 50 % to avoid interruptions during the session.
  • Backup: If you rely on location for automation (e.g., geofencing), note the current settings so you can restore them later.

Step 1 – Enable the Mock Location App

Android requires you to designate a single app as the “mock location provider”. We’ll use a tiny helper app that does nothing but expose an interface for ADB.

  1. Open the Play Store and search for “Mock GPS Provider”. Any lightweight app that declares the android.permission.ACCESS_MOCK_LOCATION permission works; Mock GPS Provider is a popular free choice.
  2. Install the app and launch it once – you’ll see a blank screen with a Start button.
  3. Return to Settings > System > Developer options.
    • Scroll to Debugging section and tap Select mock location app.
    • Choose Mock GPS Provider from the list.

Warning: Selecting a mock location app disables the device’s real GPS for all apps. Remember to switch back to “None” when you finish testing.

Step 2 – Prepare Your Coordinate Data

ADB can feed location updates in two main formats:

  • Single point: One latitude/longitude pair.
  • GPX track: A series of waypoints that simulate movement.

For most testing, a simple CSV file is enough. Create a file called mock_locations.txt on your computer with the following layout (one entry per line):

latitude,longitude,accuracy,provider
37.4219983,-122.084,5,gps
40.712776,-74.005974,10,gps
-33.868820,151.209296,8,gps

Explanation of columns:

  • latitude and longitude – decimal degrees.
  • accuracy – radius in meters; typical GPS accuracy is 5–10 m.
  • provider – usually gps or network. Using gps mimics the hardware GPS.

If you prefer a GPX file, you can export a track from tools like GPS Visualizer and save it as track.gpx. The ADB command we’ll use later can read both formats.

Step 3 – Push the Data to the Device

We’ll place the file in the mock provider’s private storage so the app can read it. The exact path varies by app, but most expose a public /sdcard/MockLocation folder.

  1. Connect the phone via USB and verify the connection:
    adb devices

    You should see your device listed as device. If it shows unauthorized, accept the prompt on the phone.

  2. Create the target directory on the phone:
    adb shell mkdir -p /sdcard/MockLocation
  3. Copy your coordinate file:
    adb push mock_locations.txt /sdcard/MockLocation/

If you are using a GPX track, push it with the same command, e.g., adb push track.gpx /sdcard/MockLocation/.

Step 4 – Start the Mock Provider via ADB

The helper app we installed listens for a broadcast intent that tells it to start feeding locations. The intent name is com.example.mockgps.START (replace com.example.mockgps with the actual package name of your chosen app; you can find it with adb shell pm list packages | grep mockgps).

Assuming the package is com.lexa.mockgps, run:

adb shell am broadcast -a com.lexa.mockgps.START \
  --es file "/sdcard/MockLocation/mock_locations.txt"

This command does three things:

  1. Broadcasts the START action to the mock app.
  2. Passes the path to the coordinate file via the file extra.
  3. Triggers the app to read the file and begin injecting locations at a default 1 Hz rate.

After a few seconds, you should see a toast notification from the mock app saying “Mock locations active”.

Step 5 – Verify the Mock Location Is Working

There are several ways to confirm that Android is using the fake coordinates.

  1. Open Google Maps on the device. The blue dot should appear at the first coordinate (e.g., Googleplex).
  2. Alternatively, run a quick ADB query:
    adb shell dumpsys location | grep "Location" -A 5

    Look for lines showing the latitude and longitude you supplied.

If the location does not change, double‑check that the mock app is still running (pull down the notification shade and look for its persistent icon). Also verify that you selected the correct mock location app in Developer options.

Step 6 – Adjust Update Frequency and Movement

By default the mock app emits one update per second. For smoother movement or slower testing you can control the interval.

Many mock apps expose an extra intent field called interval (milliseconds). Example to emit a location every 5 seconds:

adb shell am broadcast -a com.lexa.mockgps.START \
  --es file "/sdcard/MockLocation/mock_locations.txt" \
  --ei interval 5000

If you supplied a GPX track, the app usually respects the timestamps inside the file, reproducing the original speed. Some apps also let you set a speed multiplier via an extra named speed_factor.

Step 7 – Stop the Mock Provider

When you’re done, send a stop broadcast:

adb shell am broadcast -a com.lexa.mockgps.STOP

Or simply close the mock app on the phone. After stopping, Android will revert to the real GPS signal (if you have a clear view of the sky).

Alternative: Using geo fix Directly from ADB

If you prefer not to install any third‑party app, ADB itself can inject a single location using the geo fix command. This works on emulators and, on many real devices, via the adb shell “telnet” interface. The syntax is:

adb emu geo fix <longitude> <latitude> [<altitude>] [<accuracy>]

Example:

adb emu geo fix -122.084 37.4219983 0 5

Limitations:

  • Only works on emulators or devices that expose the geo service (rare on production phones).
  • Can set only one point at a time; no built‑in track playback.

For most physical devices, the mock‑location app approach described earlier is more reliable.

Troubleshooting Common Issues

1. No mock location appears in Google Maps

  • Check mock app selection: Settings > Developer options > Select mock location app must point to the app you installed.
  • Verify broadcast success: Run adb logcat | grep MockGPS after sending the START intent. Look for a line like “MockGPS: Started with file …”.
  • Battery‑saving modes: Some OEMs (e.g., Huawei, Xiaomi) aggressively kill background services. Disable battery optimization for the mock app: Settings > Battery > Battery optimization > All apps > Mock GPS Provider > “Don’t optimize”.

2. ADB reports “Permission denied” when pushing the file

  • Ensure USB debugging is enabled and the computer is authorized.
  • Use adb root only on devices that allow it (most production phones do not). Instead, push to a public folder like /sdcard/ as shown.

3. The mock app crashes after receiving the broadcast

  • Confirm the file path is correct and the file is readable. You can list it on the device:
    adb shell ls -l /sdcard/MockLocation/
  • Check the file format – no stray characters, UTF‑8 encoding, and exactly four comma‑separated fields per line.

4. Some apps still report the real location

  • Apps that request ACCESS_FINE_LOCATION from the LocationManager will receive the mock data, but apps that use Google Play Services’ fused location provider may ignore mock sources unless the device is in “developer mode”. Ensure Allow mock locations is enabled in Developer options (this is automatic when you pick a mock app).
  • If the app explicitly checks Location.isFromMockProvider(), it will know the location is fake. In that case, you cannot hide the fact without rooting.

Advanced Use Cases

  • Automated UI testing: Combine the mock location broadcast with adb shell input tap … to script end‑to‑end scenarios for location‑aware apps.
  • Geofencing validation: Feed a series of points that cross a geofence boundary and watch the app fire the expected intents.
  • Privacy sandbox experiments: Simulate a user traveling across countries to see how apps adapt their data collection policies.

Cleaning Up After Testing

  1. Stop the mock provider (see Step 7).
  2. Return to Settings > Developer options > Select mock location app and choose None.
  3. Optionally uninstall the mock app if you no longer need it.
  4. Delete the temporary files from the device:
    adb shell rm -rf /sdcard/MockLocation

After these steps, your phone will use the real GPS again, and any location‑dependent services will function normally.

Summary

By enabling a mock location app, preparing a simple coordinate file, and using ADB broadcasts, you can reliably simulate GPS positions on any Android device without rooting. This workflow gives you fine‑grained control, works across manufacturers, and integrates cleanly with automated testing pipelines. Remember to revert the mock settings when finished to avoid unexpected behavior in everyday apps.

User Comments (0)

Add Comment
We'll never share your email with anyone else.