Directions-api-client-hc: java.lang.NoSuchMethodError: okio.BufferedSource.rangeEquals(JLokio/ByteString;)Z


I have encountered a problem related to the okio dependency while using the directions-api-client-hc to send and consume a MatrixRequest to the Directions API.

This is the code in order to reproduce:

GraphHopperMatrixWeb matrixClient = new GraphHopperMatrixWeb();

GHMRequest request = new GHMRequest();
request.addFromPoints(Arrays.asList(new GHPoint(48.844055, 2.311129), new GHPoint(48.836792, 2.351729), new GHPoint(48.884376, 2.366178)));
request.addToPoints(Arrays.asList(new GHPoint(48.896827, 2.325425), new GHPoint(48.893765, 2.212104)));

MatrixResponse response = matrixClient.route(request);

This is the exception I’m having:

Exception in thread "main" java.lang.NoSuchMethodError: okio.BufferedSource.rangeEquals(JLokio/ByteString;)Z
	at okhttp3.internal.Util.bomAwareCharset(
	at okhttp3.ResponseBody.string(
	at com.graphhopper.api.GHMatrixAbstractRequester.postJson(
	at com.graphhopper.api.GHMatrixBatchRequester.route(
	at com.graphhopper.api.GraphHopperMatrixWeb.route(
	at com.praxedo.executables.forecast.ghdirectionsapi.DirectionsApi.main(

I have cleaned my local dependencies but I am still having the same problem. I’m not sure if it is related to my local environment or if it is a problem on the dependencies of the directions-api-client-hc. Can anyone confirm it ?

Thank you,

When using a fresh project (via IntelliJ) and the code below it works without the mentioned exception. I used the following maven snippet:


Do you have multiple different versions of okhttp3 in the classpath? This dependency uses 3.8.0

It turns out I had an older okhttp dependency brought by another dependecy. Nothing is wrong with the GraphHopper client, everything works fine. Sorry about that.