NavigationLauncher cannot be started with DirectionsRoute
Description
I upgraded the navigation sdk from 0.7.1 to 0.12.0. Now I cannot start the navigation using a precalculated DirectionsRoute anymore. When I call startNavigation, I only get a blue screen because my position is set to somewhere south-west of Africa. This position is not updated and no navigation started. Calling startNavigation() with origin, destination and directions profile works fine.
My dependencies are:
- Mapbox Android SDK: 5.5.0
- Mapbox Navigation and Navigation UI: 0.12.0
- LocationLayerPlugin: 0.4.0
- Mapbox Java Services und Android Services: 2.2.9
Here is my code
Using requested DirectionsRoute: DirectionsRoute route = directionsResponse.routes().get(0);
Starting Navigation with DirectionsRoute (not working): NavigationLauncherOptions navigationOptions = NavigationLauncherOptions.builder() .directionsRoute(route) .awsPoolId(null) .shouldSimulateRoute(false) .build();
NavigationLauncher.startNavigation(activity, navigationOptions);
Starting Navigation with origin and destination: final Point originPoint = Point.fromLngLat(origin.getLongitude(), origin.getLatitude()); final Point destinationPoint = Point.fromLngLat(destination.getLongitude(), destination.getLatitude());
NavigationLauncherOptions navigationOptions = NavigationLauncherOptions.builder() .origin(originPoint) .destination(destinationPoint) .directionsProfile(DirectionsCriteria.PROFILE_DRIVING_TRAFFIC) .awsPoolId(null) .shouldSimulateRoute(false) .build();
NavigationLauncher.startNavigation(activity, navigationOptions);
same issue here i start a navigation UI on button click but it does not start here is my code
> button.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
String awsPoolId = null;
boolean simulateRoute = true;
NavigationLauncherOptions.Builder optionsBuilder = NavigationLauncherOptions.builder()
.directionsProfile(DirectionsCriteria.PROFILE_CYCLING)
.origin(origin)
.destination(destination);
NavigationLauncher.startNavigation(NavigationActivity.this, optionsBuilder.build());
on button click application crash and gives this error
java.lang.RuntimeException: Unable to start activity ComponentInfo{bikerloops.brainyapp.com.bikes/com.mapbox.services.android.navigation.ui.v5.NavigationActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'void com.mapbox.services.android.navigation.ui.v5.NavigationView.onCreate(android.os.Bundle)' on a null object reference at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2646) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2707) at android.app.ActivityThread.-wrap12(ActivityThread.java) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1460) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:154) at android.app.ActivityThread.main(ActivityThread.java:6077) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:865) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755) Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'void com.mapbox.services.android.navigation.ui.v5.NavigationView.onCreate(android.os.Bundle)' on a null object reference at com.mapbox.services.android.navigation.ui.v5.NavigationActivity.onCreate(NavigationActivity.java:39) at android.app.Activity.performCreate(Activity.java:6662) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1118) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2599) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2707) at android.app.ActivityThread.-wrap12(ActivityThread.java) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1460) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:154) at android.app.ActivityThread.main(ActivityThread.java:6077) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:865) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755)
kindly help on this issue
Hey @sarahthe - the issue for this OP should be resolved in 0.13.0 - please confirm once you have updated to the new SDK.
@Meerz It looks like your issue could be related to:
NavigationLauncher.startNavigation(NavigationActivity.this, optionsBuilder.build());
Are you creating an Activity called NavigationActivity? If so, can you please update the name to something else (YourNavigationActivity)? I think there's a conflict with the Mapbox NavigationActivity bundled with the SDK. Thanks!