mapbox / mapbox/mapbox-navigation-android
NavigationLauncher.startNavigation() crashes every time i call it
- Dominant language
- Kotlin
- Stars
- 651
- Forks
- 321
- PR merge metrics
- No merged PRs in 30d
Description
**Android API:** 21
**Mapbox Navigation SDK version:** 6
### Steps to trigger behavior
I am starting the Navigation like this when Button is clicked:
NavigationLauncherOptions options = NavigationLauncherOptions.builder()
.origin(Point.fromLngLat(originLocation.getLongitude(), originLocation.getLatitude()))
.destination(destination)
.shouldSimulateRoute(true)
.build();
NavigationLauncher.startNavigation(MapMarker.this, options);
None of the parameters is "null" by the way...
### Expected behavior
It should start the NavigationActivity but ...
### Actual behavior
after the Activity gets called it crashes immediately and the next launch is my MainActivity where i get this Error:
E/ViewRootImpl@39d50d1[MapMarker]: Surface is not valid.
D/AndroidRuntime: Shutting down VM
E/AndroidRuntime: FATAL EXCEPTION: main
Process: at.hallwang.pzeproject, PID: 22633
java.lang.IllegalStateException: Can not perform this action after onSaveInstanceState
at androidx.fragment.app.FragmentManager.checkStateLoss(FragmentManager.java:1844)
at androidx.fragment.app.FragmentManager.enqueueAction(FragmentManager.java:1884)
at androidx.fragment.app.BackStackRecord.commitInternal(BackStackRecord.java:329)
at androidx.fragment.app.BackStackRecord.commit(BackStackRecord.java:294)
at at.hallwang.pzeproject.MainActivity.lambda$start$4$at-hallwang-pzeproject-MainActivity(MainActivity.java:141)
at at.hallwang.pzeproject.MainActivity$$ExternalSyntheticLambda4.onShowItem(Unknown Source:2)
at com.etebarian.meowbottomnavigation.MeowBottomNavigation.show(MeowBottomNavigation.java:378)
at com.etebarian.meowbottomnavigation.MeowBottomNavigation.onMeasure(MeowBottomNavigation.java:254)
at android.view.View.measure(View.java:26415)
at android.widget.RelativeLayout.measureChildHorizontal(RelativeLayout.java:735)
at android.widget.RelativeLayout.onMeasure(RelativeLayout.java:481)
at android.view.View.measure(View.java:26415)
at androidx.swiperefreshlayout.widget.SwipeRefreshLayout.onMeasure(SwipeRefreshLayout.java:705)
at android.view.View.measure(View.java:26415)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:7845)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:194)
at androidx.appcompat.widget.ContentFrameLayout.onMeasure(ContentFrameLayout.java:145)
at android.view.View.measure(View.java:26415)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:7845)
at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1552)
at android.widget.LinearLayout.measureVertical(LinearLayout.java:842)
at android.widget.LinearLayout.onMeasure(LinearLayout.java:721)
at android.view.View.measure(View.java:26415)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:7845)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:194)
at android.view.View.measure(View.java:26415)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:7845)
at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1552)
at android.widget.LinearLayout.measureVertical(LinearLayout.java:842)
at android.widget.LinearLayout.onMeasure(LinearLayout.java:721)
at android.view.View.measure(View.java:26415)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:7845)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:194)
at com.android.internal.policy.DecorView.onMeasure(DecorView.java:1010)
at android.view.View.measure(View.java:26415)
at android.view.ViewRootImpl.performMeasure(ViewRootImpl.java:3602)
at android.view.ViewRootImpl.measureHierarchy(ViewRootImpl.java:2345)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2693)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:2197)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:8996)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:996)
at android.view.Choreographer.doCallbacks(Choreographer.java:794)
at android.view.Choreographer.doFrame(Choreographer.java:729)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:981)
at android.os.Handler.handleCallback(Handler.java:883)
at android.os.Handler.dispatchMessage(Handler.java:100)
at android.os.Looper.loop(Looper.java:237)
at android.app.ActivityThread.main(ActivityThread.java:7860)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1075)
Except the first two lines of this Log, all Errors are caused on MainActivity...
But the "Surface is not valid" is new for me.
is it possible that there are issues with the layout from the NavigationActivity?
Contributor guide
Research direction
Start with the NavigationLauncher.startNavigation call and the reported stack trace, especially MainActivity.java:141 and the FragmentManager exception. Reproduce the crash using the supplied NavigationLauncherOptions and determine whether the failure is in NavigationActivity or the app's MainActivity; done means the navigation launch no longer crashes and the reported error is explained.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- android, java
- Domain
- mobile
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 22/100