I was trying to run a sample project "Routing" provided by ArcGis Runtime SDK. I tried the code but when the method solve() of RouteTask class is executed, it throws the following exception without returning any routes:

com.esri.core.io.EsriServiceException: Unable to complete operation. Location "Location 1" in "Stops" is unlocated. Location "Location 2" in "Stops" is unlocated. Need at least 2 valid stops. "Stops" does not contain valid input for any route.

I am not able to figure out what the actual problem is. Here is the link for the sample code and the code looks like this:

        map.setOnLongPressListener(new OnLongPressListener() {

        private static final long serialVersionUID = 1L;

        public boolean onLongPress(final float x, final float y) {

            // Clear the graphics and empty the directions list
            curDirections = new ArrayList<String>();
            mResults = null;

            // retrieve the user clicked location
            final Point loc = map.toMapPoint(x, y);

            // Show that the route is calculating
            dialog = ProgressDialog.show(RoutingSample.this, "",
                    "Calculating route...", true);
            // Spawn the request off in a new thread to keep UI responsive
            Thread t = new Thread() {

                public void run() {
                    try {
                        // Start building up routing parameters
                        RouteParameters rp = mRouteTask
                        NAFeaturesAsFeature rfaf = new NAFeaturesAsFeature();
                        // Convert point to EGS (decimal degrees)
                        Point p = (Point) GeometryEngine.project(loc, wm,
                        // Create the stop points (start at our location, go
                        // to pressed location)
                        StopGraphic point1 = new StopGraphic(mLocation);
                        StopGraphic point2 = new StopGraphic(p);
                        rfaf.setFeatures(new Graphic[] { point1, point2 });
                        // Set the routing service output SR to our map
                        // service's SR

                        // Solve the route and use the results to update UI
                        // when received
                        mResults = mRouteTask.solve(rp);
                    } catch (Exception e) {
                        Log.w(ESRI_EXCEPTION_TAG, e);
                        mException = e;
            // Start the operation
            return true;

I get exception on the following line: mResults = mRouteTask.solve(rp);

  • You do not need to generate a token to work with this sample. The error you are getting is related to a location not being properly geocoded. Please detail the steps you do to reproduce the error. – jdONeill Aug 19 '14 at 18:51
  • @jdONeill I was accessing the wrong Rest service so the location was not detectable. So, if you want to reproduce the error, you can change the url which does not cover your location or the area that you are targetting in your app. – Puneetr90 Aug 20 '14 at 6:28

I got this one myself. The problem was the rest API url that I was calling.Please follow the steps below:

  1. I had to generate the access token as mentioned in this link.

  2. After that, change your url to this http://route.arcgis.com/arcgis/rest/services/World/Route/NAServer/Route_India (As I was looking for routes in India)

  3. Than in your code, along with the above url, you will also have to pass a UserCredential object like like this:

    UserCredentials authenticate= new UserCredentials();
        mRouteTask = RouteTask

TOKEN and CLIENT_ID is generated in step 1.

Hope it helps someone.

| improve this answer | |
  • Glad you solved your issue, to be clear though, you don't need a TOKEN or CLIENT_ID to work directly with the sample – jdONeill Aug 22 '14 at 19:33
  • @jdONeill in my case , I needed one as when I tried without token it showed me unauthorized access.Also u must have using some other url. thats y u dint need any token. :) – Puneetr90 Aug 23 '14 at 7:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.