Hello all,
I'm trying to get the route data using the below code and getting the following error
private fun findRoute() {
// generate a route with directions and stops for navigation
val routeTask = RouteTask(context, BuildConfig.ARC_GIS_ROUTING_URL)
val routeParametersFuture = routeTask.createDefaultParametersAsync()
routeParametersFuture.addDoneListener {
// define the route parameters
val routeParameters = routeParametersFuture.get().apply {
try {
val routeStops = listOf(
// Destination stop
Stop(Point(longitude, latitude, SpatialReferences.getWgs84()))
)
setStops(routeStops)
isReturnDirections = true
isReturnStops = true
isReturnRoutes = true
} catch (e: Exception) {
when (e) {
is InterruptedException, is ExecutionException -> {
val error = "Error getting the default route parameters: " + e.message
Toast.makeText(activity, error, Toast.LENGTH_LONG)
.show()
Log.e(TAG, error)
}
else -> throw e
}
}
}
val routeResultFuture = routeTask.solveRouteAsync(routeParameters)
routeResultFuture.addDoneListener {
try {
// get the route geometry from the route result
val routeResult = routeResultFuture.get()
val routeGeometry = routeResult.routes[0].routeGeometry
// create a graphic for the route geometry
val routeGraphic = Graphic(
routeGeometry,
SimpleLineSymbol(SimpleLineSymbol.Style.SOLID, Color.BLUE, 5f)
)
// add it to the graphics overlay
binding.acceptMissionMapView.graphicsOverlays[0].graphics.add(routeGraphic)
// set the map view view point to show the whole route
binding.acceptMissionMapView.setViewpointAsync(Viewpoint(routeGeometry.extent))
this.routeTask = routeTask
this.routeResult = routeResult
this.routeParameters = routeParameters
} catch (e: Exception) {
when (e) {
is InterruptedException, is ExecutionException -> {
val error = "Error creating the route result: " + e.message
Toast.makeText(context, error, Toast.LENGTH_LONG)
.show()
Log.e(TAG, error)
}
else -> throw e
}
}
}
}
}
and this is the error that I'm getting:
2021-04-18 21:00:48.170 7991-7991/com.jst.poc.dispatcher E/AndroidRuntime: FATAL EXCEPTION: main Process: com.jst.poc.dispatcher, PID: 7991 java.lang.RuntimeException: java.lang.reflect.InvocationTargetException at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:602) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947) Caused by: java.lang.reflect.InvocationTargetException 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.util.concurrent.ExecutionException: com.esri.arcgisruntime.ArcGISRuntimeException: Invalid call.: Object failed to load, unable to execute task. at com.esri.arcgisruntime.internal.c.b.get(SourceFile:130) at com.jst.poc.dispatcher.features.dashboard.ui.fragments.AcceptMissionFragment$findRoute$1.run(AcceptMissionFragment.kt:186) at android.os.Handler.handleCallback(Handler.java:938) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:223) at android.app.ActivityThread.main(ActivityThread.java:7656) 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: com.esri.arcgisruntime.ArcGISRuntimeException: Invalid call.: Object failed to load, unable to execute task. at com.esri.arcgisruntime.internal.c.b.get(SourceFile:122) at com.jst.poc.dispatcher.features.dashboard.ui.fragments.AcceptMissionFragment$findRoute$1.run(AcceptMissionFragment.kt:186) at android.os.Handler.handleCallback(Handler.java:938) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:223) at android.app.ActivityThread.main(ActivityThread.java:7656) 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)