As starting point you can use the demo project which can be used from Android Studio, NetBeans, gradle or maven.
Before the installation fetch the source, the OpenStreetMap data and the dependencies:
$ git clone git://github.com/graphhopper/graphhopper.git graphhopper
$ cd graphhopper
$ ./graphhopper.sh import your-area.pbf
Please read here for a detailed instruction.
Download the Android SDK and go to the Android SDK Manager and install the latest SDK.
- Download Maven Android SDK Deployer and execute
mvn install -P 5.1
- it uses Android Maven Plugin under the hood where you need to set up ANDROID_HOME - Now do
./graphhopper.sh android
$ cd graphhopper/android
$ ./gradlew clean build
# push to device, start manually
$ gradle installDebug
Now that you have a running android app you need to copy somehow the routing and maps data.
- Download the raw openstreetmap file - you'll need that only for the next step to create the routing data
- Execute
./graphhopper.sh import <your-osm-file>
. This creates the routing data - Download a map e.g. berlin.map
- Copy berlin.map into the created berlin-gh folder
- Optional Compression Step: Bundle a graphhopper zip file via
cd berlin-gh; zip -r berlin.ghz *
- Now copy the berlin-gh folder from step 4 (or the .ghz file from step 5) to your Android device. /[download-folder]/graphhopper/maps, where the download-folder can e.g. be /mnt/sdcard/download or /storage/sdcard/Download/ - e.g. use SSHDroid:
scp -P 2222 berlin.ghz root@$URL:/mnt/sdcard/download/graphhopper/maps/
The open source Android App Pocket Maps using GraphHopper and Mapsforge. It stands under MIT
The developer of Locus has create a routing plugin for locus the source code for the add-on is available here and could be useful for other Map-apps too. The discussion is here.
The free offline map app Cruiser is using GraphHopper routing and allows also other things.
The OSMBonusPack supports the GraphHopper Routing API via a GraphHopperRoadManager and also provides map tile integration for various providers.
The GraphHopper Directions API Java client supports fetching the route and instructions from official and custom servers.
-
You have to create the graphhopper folder on your desktop and copy it to the Android storage.
-
A memory bound a* algoritm is not yet implemented so you can use disableShortcuts only for small routes.
If you encounter problems like 'trouble writing output: Too many methods: 72332; max is 65536.' or you want to reduce the size of the jar/apk size you can try to apply autojar on trove4j:
java -jar autojar-2.1/autojar.jar -o trove4j-stripped.jar -c $TROVE_SRC/target/classes @trove-class.list
where trove-class.list is a file with the required classes for GraphHopper as content:
gnu.trove.list.TDoubleList.class
gnu.trove.list.TIntList.class
gnu.trove.list.array.TDoubleArrayList.class
gnu.trove.list.array.TIntArrayList.class
gnu.trove.map.TIntObjectMap.class
gnu.trove.map.hash.TIntObjectHashMap.class
gnu.trove.map.hash.TIntIntHashMap.class
gnu.trove.set.hash.TIntHashSet.class
gnu.trove.iterator.TIntIterator.class
gnu.trove.procedure.TIntProcedure.class
gnu.trove.procedure.TObjectProcedure.class
gnu.trove.stack.array.TIntArrayStack.class
Routes for areas of up to 500km^2 are calculated in under 5s with the help of Contraction Hierarchies