Since version 26.0.0, the location simulation capability is introduced to help you debug and test app functions related to geographical locations.
When to Use
- Functional testing: Verify that service scenarios including map apps, location-based recommendation services, check-in features, and weather apps work properly, so that the app can obtain and process location information accurately.
- Edge scenario coverage: Simulate app behavior in different cities or landmarks around the world without traveling to the actual locations. For example, test whether the app's localized content is correct in cities such as Tokyo and London.
- Debugging: Reproduce bugs that occur only at specific geographic locations for quick identification and resolution.
Constraints
- A device running API version 26.0.0 or later has been connected via USB or Wi-Fi.
- Developer options must be enabled on the device.
- Only apps signed with a debug signature are supported. Apps signed with a release signature and released on AppGallery are not supported.
Procedure
- On the menu bar, choose View > Tool Windows > Device File Browser to open Device File Browser.

- Click the button shown in the figure to open the location simulation window.

- Set the location information. Two modes are available:
- Manual: used for simulating static locations. On this tab, manually enter the longitude, latitude, altitude, and azimuth of a location.

- Replay: used for simulating movement trajectories or continuous location changes. Click Open to import a local GPX file, set the interval, and click Apply to report the trajectory information in the GPX file at the specified interval.

- To disable location simulation, deselect Virtual location to restore the real geographical location of the device.
