As step 1, online MAPNIK maps are shown after both Manifest.xml and Runtime permissions for read/write external resources.
As the next step, I want to show the map of an offline Mapsforge file using Osmdroid. The context is Android 25.
Can you suggest me a good version combination of Osmdroid, Osmbonuspack and Mapsforge?
The following code I use to show the offline Mapsforge file. The complete example is in a Github project. 1 File for selecting a file, 1 file for showing the file.
private void showMapsforgeFile( File mapFile) {
File[] files = new File[1];
files[0] = mapFile;
MapsForgeTileSource.createInstance( this.getApplication());
fromFiles = MapsForgeTileSource.createFromFiles( files);
forge = new MapsForgeTileProvider( new SimpleRegisterReceiver( getBaseContext()), fromFiles);
mapView.setTileProvider(forge);
mapView.getController().setZoom( 9);
GeoPoint startPoint = new GeoPoint(52.2222, 36.6123);
}
This gives (often) the next message:
I/OsmDroid: Error downloading tile: /9/55/139 java.lang.NoSuchFieldError: No field DEBUG_TILE_PROVIDERS of type Z in class Lorg/osmdroid/tileprovider/constants/OpenStreetMapTileProviderConstants; or its superclasses etc
I tried many combinations of versions of Osmdroid, Osmdroid and Mapsforge. For example (and I used a lot of other combinations ... as shown via jitpack.io, osmdroid releases and osmbonuspack releases. The error keeps the same.
compile 'com.github.MKergall:osmbonuspack:6.1'
compile 'org.apache.commons:commons-lang3:3.3.2'
compile 'com.google.code.gson:gson:2.7'
compile 'com.squareup.okhttp3:okhttp:3.4.1'
compile 'org.osmdroid:osmdroid-android:5.5'
compile 'org.osmdroid:osmdroid-mapsforge:5.5:release@aar'
compile 'org.mapsforge:mapsforge-map-android:0.6.1'
compile 'org.mapsforge:mapsforge-map:0.6.1'
As mentioned on github, you have mismatch of versions of osmdroid libraries. Set them all to the same version and you should be good to go. Offending reference: osmdroid-mapsforge
.
https://github.com/johan974/osmdroid-mapsforge-demo/blob/master/app/build.gradle#L34
Edit:
Here's the working configuration
compile 'org.osmdroid:osmdroid-android:5.6.5'
compile 'org.osmdroid:osmdroid-mapsforge:5.6.5'
compile 'org.mapsforge:mapsforge-map-android:0.6.1'
compile 'org.mapsforge:mapsforge-map:0.6.1'
Note that it will log an error message related to rendering theme but it will render
There's also a few minor api differences which i fixed on my fork of your project and opened a pr.