ByteBuffer error on loading graph on Android

I have custom build graph files that were built with core version 0.12.

In my MainActivity I want to load these files as following:

void loadGraphStorage() {
    logUser("loading graph (" + Constants.VERSION + ") ... ");
    new GHAsyncTask<Void, Void, Path>() {
        protected Path saveDoInBackground(Void... v)  {
            GraphHopper tmph = new GraphHopper().forMobile();
            log("found graph " + hopper.getGraphHopperStorage().toString() + ", nodes:" + hopper.getGraphHopperStorage().getNodes());
            hopper = tmph;
            return null;

        protected void onPostExecute(Path o) {
            if (hasError()) {
                logUser("An error happened while creating graph:"
                        + getErrorMessage());
            } else {
                logUser("Finished loading graph. Long press to define where to start and end the route.");


and I receive this log:

/ I/GH: An error happened while creating graph:No virtual method position(I)Ljava/nio/ByteBuffer; in class Ljava/nio/ByteBuffer; or its super classes (declaration of ‘java.nio.ByteBuffer’ appears in /system/framework/core-oj.jar

Prepare finished but hopper not ready. This happens when there was an error while loading the files

I read that these errors concerning ByteBuffer classes could occure upon a JDK incompatibility?

im running:

Android 8.1 API 27

and Android Studio


can anybody help me out?

I solved the issue with compiling the Snapshot dependency in Intelij Idea (with JDK instead of eclipse (with JDK . Though I can’t tell what really caused the issue.

Moreover my research brought to daylight that compiling with JDK 9 won’t work because of the missing sun.misc library. Also the java/nio/ByteBuffer class has been changed in JDK 9 so I can’t recommend using it.

1 Like