Skip to content

IllegalStateException: The Mean Sea Level altitude of this location is not set. #12

@marcprux

Description

@marcprux

Reported on Slack:

When using the following code to get the users location with SkipKit and SkipDevice:

    @MainActor
    private func checkLocationPermissionAndStartMonitoring() async {
        if await PermissionManager.requestLocationPermission(precise: true, always: false).isAuthorized == false {
            isLocationPermissionNotEnabledAlertPresented = true
            return
        }
        
        let provider = LocationProvider()
        do {
            for try await event in provider.monitor() {
                self.event = event
            }
        } catch {
            logger.error("error updating location: \(error)")
        }
        provider.stop()
    }

... and attaching that with a .task modifier like this:

.task {
      await checkLocationPermissionAndStartMonitoring()
    }

I will get the following error on Android:

     E  FATAL EXCEPTION: main (Ask Gemini)
                                                                                                    Process: eu.karuso.main.cross, PID: 2563
                                                                                                    java.lang.IllegalStateException: The Mean Sea Level altitude of this location is not set.
                                                                                                    	at com.android.internal.util.Preconditions.checkState(Preconditions.java:215)
                                                                                                    	at android.location.Location.getMslAltitudeMeters(Location.java:715)
                                                                                                    	at skip.device.LocationEvent.<init>(LocationProvider.kt:244)
                                                                                                    	at skip.device.LocListener.onLocationChanged(LocationProvider.kt:127)
                                                                                                    	at android.location.LocationListener.onLocationChanged(LocationListener.java:63)
                                                                                                    	at android.location.LocationManager$LocationListenerTransport$1.operate(LocationManager.java:3293)
                                                                                                    	at android.location.LocationManager$LocationListenerTransport$1.operate(LocationManager.java:3290)
                                                                                                    	at 

This seems to be a bug. I have the required permissions set in AndroidManifest.xml. (edited)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions