mapbox / mapbox-navigation-android

Mapbox Navigation SDK for Android
https://docs.mapbox.com/android/navigation/overview/
Other
622 stars 319 forks source link

Snapshotter example crash mapbox_route_token #3989

Open kmadsen opened 3 years ago

kmadsen commented 3 years ago

Why crash to make devs add mapbox_route_token here? Examples would be nice to require a single mapbox_access_token

2021-02-12 14:17:32.807 18867-18867/com.mapbox.navigation.test_app E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.mapbox.navigation.test_app, PID: 18867
    java.lang.RuntimeException: Unable to start activity ComponentInfo{com.mapbox.navigation.test_app/com.mapbox.navigation.examples.core.MapboxSignboardActivity}: java.lang.RuntimeException: mapbox_route_token needed (see code comments for details)
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3431)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3595)
        at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:85)
        at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
        at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2066)
        at android.os.Handler.dispatchMessage(Handler.java:106)
        at android.os.Looper.loop(Looper.java:223)
        at android.app.ActivityThread.main(ActivityThread.java:7660)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)
     Caused by: java.lang.RuntimeException: mapbox_route_token needed (see code comments for details)
        at com.mapbox.navigation.examples.core.MapboxSignboardActivity.getMapboxRouteAccessToken(MapboxSignboardActivity.kt:266)
        at com.mapbox.navigation.examples.core.MapboxSignboardActivity.initNavigation(MapboxSignboardActivity.kt:190)
        at com.mapbox.navigation.examples.core.MapboxSignboardActivity.init(MapboxSignboardActivity.kt:177)
        at com.mapbox.navigation.examples.core.MapboxSignboardActivity.onCreate(MapboxSignboardActivity.kt:130)
        at android.app.Activity.performCreate(Activity.java:8000)
        at android.app.Activity.performCreate(Activity.java:7984)
        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1309)
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3404)
kmadsen commented 3 years ago
    /**
     * Returns the Mapbox access token set in the app resources.
     *
     * @param context The [Context] of the [android.app.Activity] or [android.app.Fragment].
     * @return The Mapbox access token or null if not found.
     */

I'm also confused by the comment, can see what it's doing but not really sure why we need it.

kmadsen commented 3 years ago

cc: @abhishek1508

abhishek1508 commented 3 years ago

You need a specific route_access_token as a part of your directions request for signboard and snapshot to work. This access_token is not the one you use for public access to maps. So just add mapbox_route_token to your mapbox_access_token.xml file with the correct token value and it will work. cc @kmadsen