Com.graphhopper.GHRequest)' on a null object reference

Yesterday I’m project is just doing fine.
Even the sample project from Git.
But then I updated my android studio to 1.5 to use the vector asset and the gradle to 1.5.
Then i got this error.

12-04 01:49:00.706 3158-3180/? E/AndroidRuntime: FATAL EXCEPTION: AsyncTask #3
                                         Process: com.juandirection.juand, PID: 3158
                                         java.lang.RuntimeException: An error occured while executing doInBackground()
                                             at android.os.AsyncTask$3.done(AsyncTask.java:304)
                                             at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:355)
                                             at java.util.concurrent.FutureTask.setException(FutureTask.java:222)
                                             at java.util.concurrent.FutureTask.run(FutureTask.java:242)
                                             at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231)
                                             at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
                                             at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
                                             at java.lang.Thread.run(Thread.java:818)
                                          Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'com.graphhopper.GHResponse com.graphhopper.GraphHopper.route(com.graphhopper.GHRequest)' on a null object reference
                                             at com.juandirection.juand.sub_activities.ViewMapPoi$2.doInBackground(ViewMapPoi.java:189)
                                             at com.juandirection.juand.sub_activities.ViewMapPoi$2.doInBackground(ViewMapPoi.java:180)
                                             at android.os.AsyncTask$2.call(AsyncTask.java:292)
                                             at java.util.concurrent.FutureTask.run(FutureTask.java:237)
                                             at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231) 
                                             at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112) 
                                             at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587) 
                                             at java.lang.Thread.run(Thread.java:818) 
12-04 01:49:00.769 3158-3158/? E/Err On Post exe: An error happend while creating graph:Version of edges unsupported: 12, expected:13

Does gradle have to do with this? thanks

Probably a coincidence, I have not seen GH behavior changes by just advancing Android build tools.

Debug your application to see what object is null according to the aforementioned exception.

Emux

In log im receiving this.
12-04 01:56:40.905 3325-3325/? E/Err On Post exe: An error happend while creating graph:Version of edges unsupported: 12, expected:13

Ah yes, you apparently play with GraphHopper SNAPSHOT code.

There was a graph structure change lately which advanced edges version to 13.
So you just need to recreate also your graph using the latest GH.

BTW it’s usually recommended to use the same GH version for creating “and” reading the graphs, to avoid such situations.

Emux

How can i recreate my graph using the latest GH?
I view my snapshot and the version is already 13.

What graph are you using - where did you get it?

There are instructions in GH site for creating graphs.

Emux

2 Days ago i cloned the sample project of GH.
Run the Git and followed the instructions on your given link.
Few days ago my project is fine, but now its not working
And for my pbf I downloaded it here. (if this what you’re talking about)
http://download.geofabrik.de

You need to update the GH version you’re using.
The Samples downloaded graphs have been updated, and don’t work with previous Samples GH versions.

To avoid such issues you could use GH 0.5 release.
(Snapshot versions are always under development changes)

Emux

If i change my GH version to GH 0.5 would that probably work?
And to i still need to re import my pbf file?

You could use:

  • either 0.5 release
  • or 0.6-SNAPSHOT

In both cases you better reimport your pbf (with that GH) in order to have matching graph.

Emux

I re cloned the project from git and re import my pbf and now its working.
But for future use maybe i should use 0.5 release. Where can i do that? thanks

It depends how you use GH (jar, Maven, Gradle), see main page in 0.5 section for instructions.

If you want to clone 0.5 you can use:
git clone -b 0.5 https://github.com/graphhopper/graphhopper.git

Emux

Thankyou. And in gradle what should i put? Will just chnage the version to 0.5?

The groupId / artifactId / version are the same in Maven and Gradle.

You can check Samples build.gradle for exact writing.

Emux

thankyou… problem solved! :smiley: