I am just writing an app which should be able to prefetch Maptiles to use the app in places where no data connection is available. For this reason I use Open Street Maps and on my Android client OSMDroid and OSMdroid Bonuspack. For production I will use my own OSM server.
This is my code for downloading the tiles of a defined area:
map.setTileSource(TileSourceFactory.MAPQUESTOSM);
map.setBuiltInZoomControls(true);
map.setMultiTouchControls(true);
BoundingBoxE6 boxE6 = new BoundingBoxE6(51.758971, 7.100778, 50.653902, 6.689312);
CacheManager cacheManager = new CacheManager(map);
cacheManager.downloadAreaAsync(getActivity(), boxE6, 13, 15);
My build.gradle contains all dependencies which are needed, according to the GitHub page of OSMdroid Bonuspack (of course no build errors):
compile 'org.osmdroid:osmdroid-android:5.0.1@aar'
compile 'org.apache.commons:commons-lang3:3.3.2'
compile 'com.google.code.gson:gson:2.3'
compile project(':osmbonuspack_v5.4')
When I run my code, the dialog appears and shows the progress of downloading the tiles for each zoom level. But my logcat flooded with the following error:
Error downloading MapTile: /15/17015/11010
java.lang.NoClassDefFoundError: org.osmdroid.http.HttpClientFactory
at org.osmdroid.bonuspack.cachemanager.CacheManager.loadTile(CacheManager.java:95)
at org.osmdroid.bonuspack.cachemanager.CacheManager$DownloadingTask.downloadArea(CacheManager.java:259)
at org.osmdroid.bonuspack.cachemanager.CacheManager$DownloadingTask.doInBackground(CacheManager.java:230)
at org.osmdroid.bonuspack.cachemanager.CacheManager$DownloadingTask.doInBackground(CacheManager.java:207)
at android.os.AsyncTask$2.call(AsyncTask.java:288)
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:841)
Proguard is disabled.