5.3.2 packed android GPS ACCESS_FINE_LOCATION not working

Hello there,

My team owns and develops a Plugin for UE that heavily relies on GPS data and we encountered a strange behavior with a packed Android project that uses GPS with Unreal Engine 5.3.2.

We analyzed the circumstances where we cannot get precise GPS position data of an android device, taking into consideration the following topics:

  • We know that you need to have GPS enabled on the device
  • We know that there are several possibilities to get GPS data, but we need the best possible up to ~3 meters.
  • We know that on android you need separate permissions depending on the desired precision.
  • We know that weather (sun, clouds, rain, and even mist) can influence GPS precision.
  • We know that it could take up to several minutes until you get a satellite “connection” to have a constantly updating GPS signal.
  • We know that on UnrealEngine you need the “Mobile Location Services - Android Implementation” and “Mobile Location Services Blueprint Library” enabled
  • We know that you need to build up a blueprint node system that checks for permissions, requests them, checks if location service is enabled, loops until its enabled by user, init location service, start location service, get location services implementation, bind to event OnLocationChanged, do something with the LocationServiceData
  • We know that the “Init Location Services” blueprint node can be configured with the field accuracy, update frequency, and min distance filter
  • We configured the project to use extra permissions
  • Mobile data, Bluetooth, and WLAN could influence the GPS precision
  • GPS accuracy may vary depending on the device used (hardware, manufacturer)
  • Time could also be a factor i.E.: when there are not enough satellites around you

All of the above-listed topics are taken into consideration, but it looks like we don’t get fine GPS location data in the project.

We created an empty test project to verify that:
When starting the application on Android, you get asked what GPS precision level you want to use. That is working as seen on the image and selection works as well.
(Images in German, sorry for that)


Sadly, when selecting “precise” and continuing, there is no GPS icon in the menu bar which indicates that the GPS chip from the device is actually NOT actively used and searching for position data.
In the image you can also see that the permissions are granted.

Clarification: There are GPS (lon/lat) values available, but they are way off, and regardless of how much time passes, it does not get better. That indicates that COARSE_LOCATION, when not even an IP-based location is used.

We noticed a precision from 140 to 50 meters which is not accurate enough for our use-case.

Interesting side note: When you use another GPS app that actually uses the device’s GPS chip properly (with GPS icon in the menu bar) then the Android UnrealEngine project actually gets the data as well. But it is not working on its own.

The screenshots were created at the exact same real-world location, so it can not be that there are external influences explaining why the UnrealEngine Android app doesn’t get proper GPS data like other GPS apps.

Has anybody encountered a similar behavior and maybe can offer a solution?

More technical background information because this topic is not long enough:

Build Log:
Ue53GpsTestProject_build_log.txt (305.4 KB)

Device used for testing:

Project configuration screenshots:








If we missed some crucial information, please let us know.
And lastly, if anyone can share with us some way to contact UE’s technical support to report that, we’d highly appreciate it, we haven’t been able to reach them directly.

Thank you in advance.

1 Like

I don’t know if you found an answer to this yet, but I just ran into the same problems and finally found a “solution”

The Provider that is being used for the requestLocationUpdates in the Android portion of the plugin is defaulting now to fused which seems to not work very well by default unless you do some other changes to support it.

Forcing the provider to use GPS caused the navigation icon in the top bar to pop back up after I called Start Location Service and the location results are working again.

FIX:

in LocationServicesAndroidImpl_UPL.xml you need to change the line from

locationManager.requestLocationUpdates(providerName, (long)LocationServicesUpdateFrequency, LocationServicesMinDistance, LocationListen);

to

locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, (long)LocationServicesUpdateFrequency, LocationServicesMinDistance, LocationListen);

Which is basically forcing it from finding a provider to forcing GPS. Note GetBestProvider() is deprecated in SDK 34 so its going to have to get replaced anyways at some point so… shrug

Now the fun part is since this is an engine plugin, you are going to need to either recompile it from source and then replace the one in the engine, or download the LocationServicesAndroidImpl plugin folder from the engine source and drop it into your Plugins folde in your project so you can change it there and use your custom one untils its “fixed”

Also another note, in 5.4 the plugin wont compile correctly and you need to change this line from

activityContext.runOnUiThread(new Runnable()

to

this.runOnUiThread(new Runnable()

In order for it to compile for 5.4 because… why not.

2 Likes

thanks a lot for sharing this solution!
After fixing the .xml file it works on my side with version 5.4.4.

Someone made a step by step wiki about the issue and how to fix:

cheers