Error message when requesting route

Hi all,

My app will display a route for a list of POI/Address…etc. In the Android studio emulator half of the time it gives me different error messages

“Error in service response: Could not parse json. Error(offset 1449984): Missing a closing quotation mark in string.”

or

“Error in service response: Could not parse json. Error(offset 1826816): Missing a colon after a name of object member.”

or

Error in service response: Could not parse json. Error(offset 1630208): Miss fraction part in number.

or

“Error in service response: Could not parse json. Error(offset 1892352): Missing a comma or ‘}’ after an object member.”

The error messages above I received after keep going back and call the activity again. After few times it finally shows the route without any error messages.

The data (i.e. the poi address) and the code (most of the time) is never change. Any idea?

Thank you

Did you try to trace these requests to check the payload?

Did you mean the url request like:

D/Request: GET {}
RequestURL https://api.tomtom.com/routing/1/calculateRoute/-41

?

The strange thing is sometimes it works properly with same set of data

Which SDK version are you using?
Can you share a piece of code that is causing this?

Hi Przemek,

Thank you for your patient first of all :slight_smile:

I am currently using com.tomtom.online:sdk-routing:2.4654

The code as below:

 private void displayRoutes() {
        tomtomMap.clear();
        if (!waypoints.isEmpty()) {
            showDialogInProgress();
            LatLng[] route = new LatLng[waypoints.size()-2]; // minus the start and end
            for (int i=1;i<waypoints.size()-1;i++){
                route[i-1]=waypoints.get(i);
            }

            RouteQuery routeQuery = new RouteQueryBuilder(waypoints.get(0),waypoints.get(waypoints.size()-1))
                    .withWayPoints(route)
                    .withRouteType(RouteType.SHORTEST)
                    .build();

            Icon startIcon  = Icon.Factory.fromResources(this,R.drawable.ic_map_route_departure);
            Icon endIcon = Icon.Factory.fromResources(this,R.drawable.ic_map_route_destination);
            routingApi.planRoute(routeQuery)
                    .subscribeOn(Schedulers.io())
                    .observeOn(AndroidSchedulers.mainThread())
                    .subscribe(new DisposableSingleObserver<RouteResponse>() {
                                   @Override
                                   public void onSuccess(RouteResponse routeResponse) {
                                       dismissDialogInProgress();
                                       displayRoutes(routeResponse.getRoutes());
                                       tomtomMap.displayRoutesOverview();
                                   }

                                   private void displayRoutes(List <FullRoute> routes) {
                                       for (FullRoute fullRoute : routes) {
                                           tomtomMap.addRoute(new RouteBuilder(
                                                   fullRoute.getCoordinates()).startIcon(startIcon).endIcon(endIcon));

                                       }
                                   }

                                   @Override
                                   public void onError(Throwable e) {
                                       dismissDialogInProgress();
                                       Toast.makeText(getApplicationContext(),e.getLocalizedMessage(), Toast.LENGTH_LONG).show();
Log.w("Route error","Error message "+e.getLocalizedMessage());
                                   }
                               }
                    );

            addMarker(); 
            tomtomMap.getUiSettings().getZoomingControlsView().show();


        } else {
            Log.w("DisplayRoute", "waypoint is empty");
        }
    }

Thank you once again.

I could not reproduce this. Maybe some specific location causes this? Can you share requests from logcat that are causing errors?

Hi Przemek,

The locations below are the one for the test

-42.83724,147.50546
-42.73597,147.43724
-42.89542,147.23825
-42.98779,147.08535
-42.88113,147.33498
-42.86876,147.36076
-42.87357,147.316
-42.88658,147.3319
-43.14262,147.8476
-43.12717,147.2575
-43.23148,147.37658
-43.31216,147.30002
-43.27021,147.34765
-43.43206,147.19812
-42.87874,147.32648
-42.02768,147.49306
-41.44666,147.12361
-41.35168,147.00242
-41.38318,146.3253
-41.57304,145.93872
-41.59632,145.93047
-41.65073,145.96204
-40.75526,145.27909
-41.05746,145.87895
-41.11309,146.07233
-41.43263,147.14565
-41.27684,148.34873
-42.02546,146.8681
-41.13302,147.34548
-41.54317,147.20594

I also suspect will that be because the computer I use for the emulator is too slow (sometimes it takes few mins to get a task done regardless android related or not)

I used these points and it works every time.

Yes it works fine now too. Not sure if because my computer is way too slow (sometimes it takes forever just for a task)…

But thank you