Android — Test Location Updates With Mock Locations (fake GPS data) in emulators and real devices

Mohammed S. Hassan
3 min readJun 1, 2020

--

Introduction

If you are building an Android app that depends on GPS locations, you know that real device testing is a nightmare. You need after each run, to move in your apartment or workplace to check if the location service and your app works as expected. Fortunately, we have nice testing options that will make this testing much easier.

Testing Location Updates on Emulator

1- Open the Android Emulator and click on the More icon (the … at the bottom of the side menu)

2- Follow the images below. You can choose Single Point or Routes. Choose Single Points.

3- Click at any point on the map to set it or use the search option to search for a place.

Here you. Now you have set a fake GPS point that should be reported on your application as if you are at this point in real world.

Routes Testing

If you want to test a case where user moving from one point to another, follow the following:

1- Select Routes instead of single points

2- Click on the map at any point then click the directions button

3- Write the start and end location you want to test then click “PLAY ROUTE”.

Enjoy :)

Testing Locations in Real Devices

Thanks to developer options, you can do similar stuff on your real device too. Follow the below steps to do the same in real phone devices.

Step 1:

Find and download any Fake GPS app from the play store

Step 2:

From your device settings, set that application as a mock location app provider.

Find the developer option in your settings. Mine was at

settings> system > developer options

Find the option select mock location app Then select the app you downloaded from step 1.

Step 3:

Open the app that you chose to download. And set location or route there.

Voila! Your Android application should now receive location updates based on what you set on that fake GPS app as if you are doing the same on the real word.

Feel free to follow me to get updates about my new articles or leave me any comments below if you have one.

Thanks for reading!

--

--

Mohammed S. Hassan

Technical Product Manager | Lead Software Engineer |Instructor