mapbox / mapbox-navigation-android

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

Check codes returned from the Directions and Map Matching APIs #1919

Open devotaaabel opened 5 years ago

devotaaabel commented 5 years ago
Fatal Exception: java.lang.NullPointerException: Attempt to invoke interface method 'java.lang.Object java.util.List.get(int)' on a null object reference
at com.mapbox.services.android.navigation.v5.navigation.RouteAnnotationUpdater.update(RouteAnnotationUpdater.java:18)
at com.mapbox.services.android.navigation.v5.navigation.RouteRefreshCallback.onResponse(RouteRefreshCallback.java:33)
at retrofit2.ExecutorCallAdapterFactory$ExecutorCallbackCall$1$1.run(ExecutorCallAdapterFactory.java:70)
at android.os.Handler.handleCallback(Handler.java:761)
at android.os.Handler.dispatchMessage(Handler.java:98)
at android.os.Looper.loop(Looper.java:156)
at android.app.ActivityThread.main(ActivityThread.java:6623)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:942)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:832)

I haven't been able to reproduce this. I have this PR but we need to track down the API call that is causing this issue. Wondering if we could send a non-crashing crash report.

Guardiola31337 commented 5 years ago

If there's a no match Route Refresh API now it produces a 200 with the following response

{
    "code": "NoMatch",
    "message": "No matching found",
    "route": {}
}

That was serialized into a route objects with no legs, causing OP's NPE when trying to obtain the legs in https://github.com/mapbox/mapbox-navigation-android/blob/9b22ca69d42bc5619aaab9a88346e2b34084ca49/libandroid-navigation/src/main/java/com/mapbox/services/android/navigation/v5/navigation/RouteAnnotationUpdater.java#L18

Although https://github.com/mapbox/mapbox-navigation-android/pull/1916 fixed the issue we should 👀 the NoMatch code moving forward.

cc'ing @osana for MAS visibility

Also noting that there are other special codes returned from the Directions and Map Matching APIs (i.e. NoSegment and NoRoute) that we should also take into account.

cc @onesien

stale[bot] commented 4 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

Guardiola31337 commented 4 years ago

This is still an issue.

stale[bot] commented 3 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.