mapbox / mapbox/mapbox-navigation-android
Crash when MapboxTripService is starting
Nobody has claimed this yet.
- Dominant language
- Kotlin
- Stars
- 651
- Forks
- 321
- PR merge metrics
- No merged PRs in 30d
Description
I've been getting a lot of crash reports from Firebase lately.
Here's the info I got from Firebase
It seems to be a bug related to starting Mapbox Service from the Background while running with Android Auto
I can't reproduce it yet
I'll update if I find a way to figure it out
**Android API:** 34
**Mapbox Navigation SDK version:** 2.20.2
### Stack Traces
> Fatal Exception: java.lang.RuntimeException: Unable to start service com.mapbox.navigation.core.trip.service.NavigationNotificationService@81f8e73 with Intent { cmp=com.sg.ncs.breeze/com.mapbox.navigation.core.trip.service.NavigationNotificationService }: java.lang.SecurityException: Starting FGS with type location callerApp=ProcessRecord{feee410 7408:com.sg.ncs.breeze/u0a346} targetSDK=34 requires permissions: all of the permissions allOf=true [android.permission.FOREGROUND_SERVICE_LOCATION] any of the permissions allOf=false [android.permission.ACCESS_COARSE_LOCATION, android.permission.ACCESS_FINE_LOCATION] and the app must be in the eligible state/exemptions to access the foreground only permission
> at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:5137)
> at android.app.ActivityThread.-$$Nest$mhandleServiceArgs()
> at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2474)
> at android.os.Handler.dispatchMessage(Handler.java:106)
> at android.os.Looper.loopOnce(Looper.java:222)
> at android.os.Looper.loop(Looper.java:314)
> at android.app.ActivityThread.main(ActivityThread.java:8779)
> at java.lang.reflect.Method.invoke(Method.java)
> at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:569)
> at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1090)
>
> Caused by java.lang.SecurityException: Starting FGS with type location callerApp=ProcessRecord{feee410 7408:com.sg.ncs.breeze/u0a346} targetSDK=34 requires permissions: all of the permissions allOf=true [android.permission.FOREGROUND_SERVICE_LOCATION] any of the permissions allOf=false [android.permission.ACCESS_COARSE_LOCATION, android.permission.ACCESS_FINE_LOCATION] and the app must be in the eligible state/exemptions to access the foreground only permission
> at android.os.Parcel.createExceptionOrNull(Parcel.java:3057)
> at android.os.Parcel.createException(Parcel.java:3041)
> at android.os.Parcel.readException(Parcel.java:3024)
> at android.os.Parcel.readException(Parcel.java:2966)
> at android.app.IActivityManager$Stub$Proxy.setServiceForeground(IActivityManager.java:7282)
> at android.app.Service.startForeground(Service.java:775)
> at com.mapbox.navigation.core.trip.service.NavigationNotificationService.notificationDataObserver$lambda-0(NavigationNotificationService.kt:23)
> at com.mapbox.navigation.core.trip.service.MapboxTripService$Companion.registerOneTimeNotificationDataObserver$libnavigation_core_release(MapboxTripService.kt:45)
> at com.mapbox.navigation.core.trip.service.NavigationNotificationService.onStartCommand(NavigationNotificationService.kt:50)
> at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:5119)
> at android.app.ActivityThread.-$$Nest$mhandleServiceArgs()
> at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2474)
> at android.os.Handler.dispatchMessage(Handler.java:106)
> at android.os.Looper.loopOnce(Looper.java:222)
> at android.os.Looper.loop(Looper.java:314)
> at android.app.ActivityThread.main(ActivityThread.java:8779)
> at java.lang.reflect.Method.invoke(Method.java)
> at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:569)
> at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1090)
>
> Caused by android.os.RemoteException: Remote stack trace:
> at com.android.server.am.ActiveServices.validateForegroundServiceType(ActiveServices.java:2750)
> at com.android.server.am.ActiveServices.setServiceForegroundInnerLocked(ActiveServices.java:2461)
> at com.android.server.am.ActiveServices.setServiceForegroundLocked(ActiveServices.java:1752)
> at com.android.server.am.ActivityManagerService.setServiceForeground(ActivityManagerService.java:14064)
> at android.app.IActivityManager$Stub.onTransact$setServiceForeground$(IActivityManager.java:12784)
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the Android API 34 foreground-service requirements and trace the reported startup path through NavigationNotificationService.kt, MapboxTripService.kt, and onStartCommand. Investigate the Android Auto/background conditions described in the report; done means the service startup no longer crashes under the reported conditions, with the cause and verification documented.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- android, kotlin
- Domain
- mobile
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100