maplibre / maplibre-navigation-android

Maplibre Navigation SDK for Android
MIT License
96 stars 53 forks source link

BLOCKER - Navigation SDk crash when we start the navigation on Android 14 #116

Closed imranMnts closed 2 months ago

imranMnts commented 2 months ago

The app crashes when we launch the navigation (when startNavigation triggers startForeground)

Crashlog:

android.app.MissingForegroundServiceTypeException: Starting FGS without a type callerApp=ProcessRecord{fa20261 15370:com.myapp/u0a440} targetSDK=34 at android.app.MissingForegroundServiceTypeException$1.createFromParcel(MissingForegroundServiceTypeException.java:53) at android.app.MissingForegroundServiceTypeException$1.createFromParcel(MissingForegroundServiceTypeException.java:49) at android.os.Parcel.readParcelableInternal(Parcel.java:4882) at android.os.Parcel.readParcelable(Parcel.java:4864) at android.os.Parcel.createExceptionOrNull(Parcel.java:3064) at android.os.Parcel.createException(Parcel.java:3053) at android.os.Parcel.readException(Parcel.java:3036) at android.os.Parcel.readException(Parcel.java:2978) at android.app.IActivityManager$Stub$Proxy.setServiceForeground(IActivityManager.java:7234) at android.app.Service.startForeground(Service.java:775) at com.mapbox.services.android.navigation.v5.navigation.NavigationService.startForegroundNotification(NavigationService.java:134) at com.mapbox.services.android.navigation.v5.navigation.NavigationService.startNavigation(NavigationService.java:69) at com.mapbox.services.android.navigation.v5.navigation.MapboxNavigation.onServiceConnected(MapboxNavigation.java:721) at android.app.LoadedApk$ServiceDispatcher.doConnected(LoadedApk.java:2348) at android.app.LoadedApk$ServiceDispatcher$RunConnection.run(LoadedApk.java:2385) at android.os.Handler.handleCallback(Handler.java:958) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loopOnce(Looper.java:230) at android.os.Looper.loop(Looper.java:319) at android.app.ActivityThread.main(ActivityThread.java:8919) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:578) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1103)

Steps to trigger behavior

  1. Display the map
  2. Launch a navigation via startNavigation method

Expected behavior

It launches the application with notification updates

Actual behavior

Application crashs on Android

Project setup:

rubenmx commented 2 months ago

You should be able to fix this by adding the NavigationService to your manifest and adding a foregroundServiceType:

<service
    android:name="com.mapbox.services.android.navigation.v5.navigation.NavigationService"
    android:exported="false"
    android:foregroundServiceType="location" />