Android | How to know the source code branch against the snapshot build

Hi all,
I’m stuck in this issue for quite some time now. I have created routing data from 0.8 branch of source code and I’m getting this exception
java.lang.IllegalStateException: Version of nodes unsupported: 3, expected:5. Make sure you are using the same GraphHopper version for reading the files that was used for creating them. See https://discuss.graphhopper.com/t/722

In my app/build.gradle I have tried 0.8-SNAPSHOT and 0.9-SNAPSHOT but no luck. Please guide how to know the exact source code branch against the snapshot we are using so I can create the route date with correct version.

implementation(group: ‘com.graphhopper’, name: ‘graphhopper-core’, version: ‘0.8-SNAPSHOT’) {
exclude group: ‘com.google.protobuf’, module: ‘protobuf-java’
exclude group: ‘org.openstreetmap.osmosis’, module: ‘osmosis-osm-binary’
exclude group: ‘org.apache.xmlgraphics’, module: ‘xmlgraphics-commons’
}

It’s exactly as it says. You need to clear the cache and recreate the road network files from your pbf.
You can do this manually or through code.

1 Like

@Gregws Thanks for the reply. You mean, clear cache of my Android Studio (Invaliate and restart)? BTW this is my project level gradle
allprojects {
repositories {
jcenter()
google()
maven { url “https://oss.sonatype.org/content/groups/public/” }
}

I have even tried this
maven { url “https://oss.sonatype.org/content/repositories/snapshots/” }

I’m not sure if this is important. I’m using ubuntu, this command was failing

./graphhopper.sh -a import -i slovenia-latest.osm.pbf

using java (64bit) from

./graphhopper.sh: line 185: [: ==: unary operator expected
./graphhopper.sh: line 85: mvn: command not found

existing jar found tools/target/graphhopper-tools-0.8.2-jar-with-dependencies.jar

now -a. JAVA_OPTS=-Xmx1000m -Xms1000m -server

so i used this one and it successfully created the route data

./graphhopper.sh import slovenia-latest.osm.pbf

using java (64bit) from

using existing osm file slovenia-latest.osm.pbf

./graphhopper.sh: line 85: mvn: command not found

existing jar found tools/target/graphhopper-tools-0.8.2-jar-with-dependencies.jar

now import. JAVA_OPTS=-Xmx1000m -Xms1000m -server

2019-12-08 11:22:53,881 [main] INFO com.graphhopper.reader.osm.GraphHopperOSM - version 0.8.2|2019-12-07T19:53:15Z (5,14,4,3,3,2)
2019-12-08 11:22:53,889 [main] INFO com.graphhopper.reader.osm.GraphHopperOSM - graph CH|car|RAM_STORE|2D|NoExt|, details:edges:0(0MB), nodes:0(0MB), name:(0MB), geo:0(0MB), bounds:1.7976931348623157E308,-1.7976931348623157E308,1.7976931348623157E308,-1.7976931348623157E308, CHGraph|fastest|car, shortcuts:0, nodesCH:(0MB)
2019-12-08 11:22:54,041 [main] INFO com.graphhopper.reader.osm.GraphHopperOSM - start creating graph from slovenia-latest.osm.pbf
2019-12-08 11:22:54,042 [main] INFO com.graphhopper.reader.osm.GraphHopperOSM - using CH|car|RAM_STORE|2D|NoExt|, memory:totalMB:958, usedMB:25
2019-12-08 11:23:10,032 [main] INFO com.graphhopper.reader.osm.OSMReader - 50 000 (preprocess), osmWayMap:0 totalMB:971, usedMB:533
2019-12-08 11:23:10,316 [main] INFO com.graphhopper.reader.osm.OSMReader - creating graph. Found nodes (pillar+tower):3 155 870, totalMB:970, usedMB:606
2019-12-08 11:23:24,171 [main] INFO com.graphhopper.reader.osm.OSMReader - 34 103 363, now parsing ways
2019-12-08 11:23:31,401 [main] INFO com.graphhopper.reader.osm.OSMReader - 36 017 955, now parsing relations
2019-12-08 11:23:31,624 [main] INFO com.graphhopper.reader.osm.OSMReader - finished way processing. nodes: 319038, osmIdMap.size:3157850, osmIdMap:39MB, nodeFlagsMap.size:1980, relFlagsMap.size:0, zeroCounter:1948 totalMB:975, usedMB:353
2019-12-08 11:23:31,625 [main] INFO com.graphhopper.reader.osm.OSMReader - time pass1:16s, pass2:21s, total:37s
2019-12-08 11:23:31,626 [main] INFO com.graphhopper.reader.osm.GraphHopperOSM - start finding subnetworks, totalMB:975, usedMB:354
2019-12-08 11:23:31,874 [main] INFO com.graphhopper.routing.subnetwork.PrepareRoutingSubnetworks - car findComponents time:0.24754164, size:3370
2019-12-08 11:23:32,079 [main] INFO com.graphhopper.routing.subnetwork.PrepareRoutingSubnetworks - 9684 subnetworks found for car, totalMB:975, usedMB:411
2019-12-08 11:23:32,146 [main] INFO com.graphhopper.routing.subnetwork.PrepareRoutingSubnetworks - optimize to remove subnetworks (9684), unvisited-dead-end-nodes (6923), maxEdges/node (7)
2019-12-08 11:23:32,253 [main] INFO com.graphhopper.reader.osm.GraphHopperOSM - edges: 361704, nodes 309355, there were 9684 subnetworks. removed them => 9683 less nodes
2019-12-08 11:23:33,127 [main] INFO com.graphhopper.storage.index.LocationIndexTree - location index created in 0.87162286s, size:457 573, leafs:171 452, precision:300, depth:5, checksum:309355, entries:[64, 64, 64, 4, 4], entriesPerLeaf:2.668811
2019-12-08 11:23:33,145 [main] INFO com.graphhopper.routing.ch.CHAlgoFactoryDecorator - 1/1 calling prepare.doWork for fastest|car … (totalMB:975, usedMB:391)
2019-12-08 11:23:33,842 [fastest_car] INFO com.graphhopper.routing.ch.PrepareContractionHierarchies - 0, updates:0, nodes: 309 355, shortcuts:0, dijkstras:1 127 845, t(dijk):0.24, t(period):0.0, t(lazy):0.0, t(neighbor):0.0, meanDegree:1, algo:4MB, totalMB:975, usedMB:417
2019-12-08 11:23:34,198 [fastest_car] INFO com.graphhopper.routing.ch.PrepareContractionHierarchies - 61 860, updates:0, nodes: 247 495, shortcuts:9, dijkstras:1 151 803, t(dijk):0.39, t(period):0.0, t(lazy):0.0, t(neighbor):0.2, meanDegree:1, algo:4MB, totalMB:975, usedMB:420
2019-12-08 11:23:36,779 [fastest_car] INFO com.graphhopper.routing.ch.PrepareContractionHierarchies - 123 720, updates:1, nodes: 185 635, shortcuts:4 588, dijkstras:2 091 421, t(dijk):2.46, t(period):2.21, t(lazy):0.0, t(neighbor):0.34, meanDegree:1, algo:4MB, totalMB:975, usedMB:438
2019-12-08 11:23:39,509 [fastest_car] INFO com.graphhopper.routing.ch.PrepareContractionHierarchies - 185 580, updates:2, nodes: 123 775, shortcuts:50 721, dijkstras:2 913 628, t(dijk):4.69, t(period):4.04, t(lazy):0.0, t(neighbor):0.73, meanDegree:1, algo:4MB, totalMB:975, usedMB:459
2019-12-08 11:23:42,188 [fastest_car] INFO com.graphhopper.routing.ch.PrepareContractionHierarchies - 247 440, updates:3, nodes: 61 915, shortcuts:102 489, dijkstras:3 587 638, t(dijk):6.92, t(period):5.66, t(lazy):0.0, t(neighbor):1.18, meanDegree:1, algo:4MB, totalMB:975, usedMB:478
2019-12-08 11:23:46,918 [fastest_car] INFO com.graphhopper.routing.ch.PrepareContractionHierarchies - 309 300, updates:4, nodes: 11 077, shortcuts:164 814, dijkstras:4 434 035, t(dijk):11.08, t(period):6.95, t(lazy):1.14, t(neighbor):2.33, meanDegree:2, algo:4MB, totalMB:975, usedMB:496
2019-12-08 11:23:50,547 [fastest_car] INFO com.graphhopper.routing.ch.PrepareContractionHierarchies - took:17, new shortcuts: 188 081, prepare|fastest, dijkstras:4950572, t(dijk):14.45, t(period):7.61, t(lazy):2.34, t(neighbor):3.41, meanDegree:1, initSize:309355, periodic:20, lazy:10, neighbor:20, totalMB:975, usedMB:500
2019-12-08 11:23:50,548 [main] INFO com.graphhopper.reader.osm.GraphHopperOSM - flushing graph CH|car|RAM_STORE|2D|NoExt|5,14,4,3,3, details:edges:361 704(12MB), nodes:309 355(4MB), name:(1MB), geo:4 343 627(17MB), bounds:13.359269239588139,19.453869449806277,41.31469092476422,47.12469701747664, CHGraph|fastest|car, shortcuts:188 081, nodesCH:(3MB), totalMB:975, usedMB:500)
2019-12-08 11:23:50,590 [main] INFO com.graphhopper.reader.osm.GraphHopperOSM - flushed graph totalMB:975, usedMB:516)

Clearing the cache of Android Studio and rebuilding route data using ./graphhopper.sh import slovenia-latest.osm.pbf this solve the problem.
@karussell @devemux86 any idea guys? I’m already spent last night trying to figure out but no luck. Please help

Hey,
We are using different platforms but it should be similar. I mean clearing the graph cache.
I’m not an expert in all applications of graphhopper and I can only speak to my experiences.

eg.
GraphHopper graphHopper = new GraphHopper().setGraphHopperLocation(LocationGraphhopperFiles) // “gh-car”
.setEncodingManager(new EncodingManager(“car”))
.setOSMFile(LocationRoutingFile)
.forDesktop();

LocationGraphhopperFiles = graph cache location
LocationRoutingFile = pbf location

Navigating to the cache location I have;
image
If I manually delete those then it rebuilds the cache on run.

Alternatively you can clean the cache through code;
GraphHopper graphHopper = new GraphHopper().setGraphHopperLocation(LocationGraphhopperFiles).forDesktop();
graphHopper.clean();
graphHopper.close();

graphHopper.importOrLoad(); will either load the existing cached files or import new ones (or the other way around)

You are manually creating the graph cache I presume and the differences in versions is causing the error. I found it easier to allow the graphhopper dependency to create its own.

1 Like

You are genius. Why it didn’t come to my mind lol. I was trying all the different things but forgot that the graph data is not going to be copy every time. Thank you very much Gregws.

Best
Muhammad Babar

Glad to have been able to help you.
I had the same issue at one point :slight_smile:

1 Like

Same issue, ( Android) This is a fresh build with fresh .pbf and map files
An error happened while creating graph:Version of edges unsupported: 14, expected:15. Make sure you are using the same GraphHopper version for reading the files that was used for creating them.

As per gregws advice above I deleted all the graph files ( on the phones “Internal storage\Download\graphhopper\maps\new-zealand-latest-gh” directory, except for the map

This produced: , "An error happened while creating graph:Cannot load properties to fetch EncodingManager configuration at: /storage/emulated/0/Download/graphhopper/maps/new-zealand-latest-gh/

So I reinstated the properties file, so just the properties file and the map in the directory I get the old error mesage back again
I/GH: An error happened while creating graph:Version of edges unsupported: 14, expected:15. Make sure you are using the same GraphHopper version for reading the files that was used for creating them. See https://…

Build log as follows
$ ./graphhopper.sh -a import -i new-zealand-latest.osm.pbf

using java from C:\Program Files\Java\jdk1.8.0_201

using existing osm file new-zealand-latest.osm.pbf

existing jar found web/target/graphhopper-web-0.13-SNAPSHOT.jar

now import. JAVA_OPTS=-Xmx1000m -Xms1000m

2019-12-11 17:51:22.187 [main] INFO c.g.reader.osm.GraphHopperOSM - version 0.13|2019-11-18T07:52:46Z (5,14,4,3,3,3)
2019-12-11 17:51:22.194 [main] INFO c.g.reader.osm.GraphHopperOSM - graph CH|car|RAM_STORE|2D|NoExt|, details:edges:0(0MB), nodes:0(0MB), name:(0MB), geo:0(0MB), bounds:1.7976931348623157E308,-1.7976931348623157E308,1.7976931348623157E308,-1.7976931348623157E308, CHGraph|fastest|car|edge_based=false, shortcuts:0, nodesCH:(0MB)
2019-12-11 17:51:22.262 [main] INFO c.g.reader.osm.GraphHopperOSM - start creating graph from new-zealand-latest.osm.pbf
2019-12-11 17:51:22.262 [main] INFO c.g.reader.osm.GraphHopperOSM - using CH|car|RAM_STORE|2D|NoExt|, memory:totalMB:958, usedMB:36
2019-12-11 17:51:43.022 [main] INFO com.graphhopper.reader.osm.OSMReader - creating graph. Found nodes (pillar+tower):3▒092▒623, totalMB:935, usedMB:417
2019-12-11 17:52:00.415 [main] INFO com.graphhopper.reader.osm.OSMReader - 29▒719▒281, now parsing ways
2019-12-11 17:52:07.966 [main] INFO com.graphhopper.reader.osm.OSMReader - 31▒515▒504, now parsing relations
2019-12-11 17:52:07.977 [main] INFO com.graphhopper.reader.osm.OSMReader - finished way processing. nodes: 389001, osmIdMap.size:3097015, osmIdMap:38MB, nodeFlagsMap.size:4392, relFlagsMap.size:0, zeroCounter:4222 totalMB:945, usedMB:537
2019-12-11 17:52:07.977 [main] INFO com.graphhopper.reader.osm.OSMReader - time pass1:20s, pass2:24s, total:45s
2019-12-11 17:52:07.979 [main] INFO c.g.r.s.PrepareRoutingSubnetworks - start finding subnetworks (min:200, min one way:200) totalMB:945, usedMB:537
2019-12-11 17:52:08.319 [main] INFO c.g.r.s.PrepareRoutingSubnetworks - car-access|version=-318709518|bits=1|index=0|shift=24|store_both_directions=true findComponents time:0.3392332, size:9378
2019-12-11 17:52:08.496 [main] INFO c.g.r.s.PrepareRoutingSubnetworks - 30212 subnetworks found for car, totalMB:945, usedMB:645
2019-12-11 17:52:08.727 [main] INFO c.g.r.s.PrepareRoutingSubnetworks - optimize to remove subnetworks (30212), unvisited-dead-end-nodes (22274), maxEdges/node (9)
2019-12-11 17:52:09.000 [main] INFO c.g.reader.osm.GraphHopperOSM - edges: 454▒731, nodes 358▒790, there were 30▒212 subnetworks. removed them => 30▒211 less nodes
2019-12-11 17:52:09.931 [main] INFO c.g.storage.index.LocationIndexTree - location index created in 0.9263888s, size:813▒427, leafs:414▒043, precision:300, depth:7, checksum:358790, entries:[16, 16, 16, 16, 16, 4, 4], entriesPerLeaf:1.9645954
2019-12-11 17:52:09.954 [main] INFO c.g.r.ch.CHAlgoFactoryDecorator - 1/1 calling CH prepare.doWork for fastest|car|edge_based=false … (totalMB:937, usedMB:524)
2019-12-11 17:52:13.322 [fastest_car_node] INFO c.g.r.c.PrepareContractionHierarchies - nodes: 358▒790, shortcuts: 0, updates: 0, checked-nodes: 0, t(total): 3.36, t(period): 3.34, t(lazy): 0.00, t(neighbor): 0.00, t(contr): 0.00, t(other) : 0.03, dijkstra-ratio: 45.50%, meanDegree: 1.00, dijkstras: 1▒318▒458, mem: 5MB, totalMB:937, usedMB:555
2019-12-11 17:52:18.474 [fastest_car_node] INFO c.g.r.c.PrepareContractionHierarchies - nodes: 287▒032, shortcuts: 87, updates: 1, checked-nodes: 71▒758, t(total): 8.52, t(period): 7.88, t(lazy): 0.00, t(neighbor): 0.24, t(contr): 0.13, t(other) : 0.27, dijkstra-ratio: 55.91%, meanDegree: 1.00, dijkstras: 2▒395▒368, mem: 5MB, totalMB:937, usedMB:584
2019-12-11 17:52:22.956 [fastest_car_node] INFO c.g.r.c.PrepareContractionHierarchies - nodes: 215▒274, shortcuts: 15▒660, updates: 2, checked-nodes: 143▒516, t(total): 13.00, t(period): 11.60, t(lazy): 0.00, t(neighbor): 0.51, t(contr): 0.44, t(other) : 0.45, dijkstra-ratio: 58.46%, meanDegree: 1.67, dijkstras: 3▒249▒727, mem: 5MB, totalMB:937, usedMB:611
2019-12-11 17:52:28.057 [fastest_car_node] INFO c.g.r.c.PrepareContractionHierarchies - nodes: 143▒516, shortcuts: 80▒527, updates: 3, checked-nodes: 215▒274, t(total): 18.10, t(period): 14.83, t(lazy): 0.00, t(neighbor): 1.29, t(contr): 1.34, t(other) : 0.64, dijkstra-ratio: 60.66%, meanDegree: 1.96, dijkstras: 4▒060▒911, mem: 5MB, totalMB:937, usedMB:644
2019-12-11 17:52:32.462 [fastest_car_node] INFO c.g.r.c.PrepareContractionHierarchies - nodes: 71▒758, shortcuts: 146▒800, updates: 4, checked-nodes: 287▒032, t(total): 22.51, t(period): 17.14, t(lazy): 0.00, t(neighbor): 2.16, t(contr): 2.37, t(other) : 0.84, dijkstra-ratio: 61.96%, meanDegree: 2.00, dijkstras: 4▒699▒103, mem: 5MB, totalMB:937, usedMB:677
2019-12-11 17:52:40.271 [fastest_car_node] INFO c.g.r.c.PrepareContractionHierarchies - nodes: 12▒532, shortcuts: 236▒446, updates: 5, checked-nodes: 358▒790, t(total): 30.32, t(period): 18.52, t(lazy): 1.99, t(neighbor): 4.38, t(contr): 4.34, t(other) : 1.08, dijkstra-ratio: 65.36%, meanDegree: 4.12, dijkstras: 5▒617▒988, mem: 5MB, totalMB:942, usedMB:523
2019-12-11 17:52:47.268 [fastest_car_node] INFO c.g.r.c.PrepareContractionHierarchies - nodes: 0, shortcuts: 274▒501, updates: 5, checked-nodes: 377▒302, t(total): 37.31, t(period): 18.52, t(lazy): 4.41, t(neighbor): 7.53, t(contr): 5.68, t(other) : 1.17, dijkstra-ratio: 68.60%, meanDegree: 1.07, dijkstras: 6▒393▒033, mem: 5MB, totalMB:942, usedMB:535
2019-12-11 17:52:47.268 [fastest_car_node] INFO c.g.r.c.PrepareContractionHierarchies - new shortcuts: 274▒501, initSize:358▒790, prepare|fastest, periodic:20, lazy:10, neighbor:20, t(total): 37.31, t(period): 18.52, t(lazy): 4.41, t(neighbor): 7.53, t(contr): 5.68, t(other) : 1.17, dijkstra-ratio: 68.60%, lazy-overhead: 5%, totalMB:942, usedMB:535
2019-12-11 17:52:47.269 [fastest_car_node] INFO c.g.r.c.PrepareContractionHierarchies - took: 37s, graph now - num edges: 454▒731, num nodes: 358▒790, num shortcuts: 274▒501
2019-12-11 17:52:47.270 [main] INFO c.g.reader.osm.GraphHopperOSM - flushing graph CH|car|RAM_STORE|2D|NoExt|5,14,4,3,3, details:edges:454▒731(14MB), nodes:358▒790(5MB), name:(2MB), geo:4▒682▒032(18MB), bounds:167.15082080254302,178.5443738,-46.92564637047752,-34.3977855, CHGraph|fastest|car|edge_based=false, shortcuts:274▒501, nodesCH:(3MB), totalMB:942, usedMB:537)
2019-12-11 17:52:47.476 [main] INFO c.g.reader.osm.GraphHopperOSM - flushed graph totalMB:942, usedMB:569)
2019-12-11 17:52:47.477 [main] INFO c.g.http.GraphHopperManaged - loaded graph at:./new-zealand-latest.osm-gh, data_reader_file:new-zealand-latest.osm.pbf, encoded values:roundabout|version=283388307|bits=1|index=0|shift=0|store_both_directions=false,road_class|version=888755028|bits=5|index=0|shift=1|store_both_directions=false,road_class_link|version=146075245|bits=1|index=0|shift=6|store_both_directions=false,road_environment|version=-446726394|bits=3|index=0|shift=7|store_both_directions=false,max_speed|version=-1300485567|bits=5|index=0|shift=10|store_both_directions=true,road_access|version=-313723172|bits=4|index=0|shift=20|store_both_directions=false, edges:454▒731(14MB), nodes:358▒790(5MB), name:(2MB), geo:4▒682▒032(18MB), bounds:167.15082080254302,178.5443738,-46.92564637047752,-34.3977855, CHGraph|fastest|car|edge_based=false, shortcuts:274▒501, nodesCH:(3MB)

Hi James,
You need to use same version of graphhopper library in your android project as gradle dependency that you used to create the route data.

2 Likes