7

I have a developed, deployed and previously successful application which uses Osmdroid to load tiles from the default tile provider which is Mapnik

mMapView.setTileSource(TileSourceFactory.DEFAULT_TILE_SOURCE);

or

mMapView.setTileSource(TileSourceFactory.MAPNIK);

Until recently (maybe since today) the tiles on real devices (a phone and a tablet) do not load anymore. I am using osmdroid version 3.0.5. If I try the latest 4.0 version in a small sample project on an emulator, I see '403 forbidden responses' in the logcat when trying to download maptiles. If I switch the tile source to

mMapView.setTileSource(TileSourceFactory.MAPQUESTOSM);

then the map is visible with no problem. I don't see any reported issues on the Osmdroid web site issues list, nor does a Google search reveal any new problems reported, so I am asking if anyone else sees this new behaviour from Mapnik and might know of a fix?

NickT
  • 23,844
  • 11
  • 78
  • 121

4 Answers4

5

Having the same problem as well.

Unfortunately, it seems that osmdroid was banned from accessing http://tile.openstreetmap.org. Reading the tile usage policy, I found these two things which might explain why osmdroid got banned:

Heavy use (e.g. distributing an app that uses tiles from openstreetmap.org) is forbidden without prior permission from the System Administrators.

and

Valid User-Agent identifying application. Faking another app's User-Agent WILL get you blocked.

(osmdroid's useragent is "Apache-HttpClient/UNAVAILABLE (java 1.4)" which is pretty generic)

user3210008
  • 766
  • 6
  • 7
  • It would be nice if osmdroid would allow to set the user agent (does it already?) as I think this would solve the problem. It already limits access threads to 2 explicitly to comply with OSMs usage policy. – Torsten Römer Jan 18 '14 at 20:50
  • 2
    I looked at the osmdroid's source code, and I couldn't find any way to manually change the user-agent. So, I created a patch that will change the user-agent to something that's more compliant with OSM's tile usage policy. You can find more information here: http://code.google.com/p/osmdroid/issues/detail?id=515 – user3210008 Jan 20 '14 at 01:43
  • since 5.1 it's changable – spy Jun 05 '16 at 19:02
5

Please follow Issue 515 to track this issue. We have implemented a fix and we will release a proper update soon.

kurtzmarc
  • 3,110
  • 1
  • 24
  • 40
  • Thank you very much. I had been tracking 515 and have temporarily made a patched jar. I look forward to the new release though, as I prefer to use an official binary. – NickT Jan 20 '14 at 18:14
  • 1
    Version 4.1 jar fixes the issue now. Thanks very much – NickT Jan 28 '14 at 11:07
1

From OpenPisteMap:

If you start getting "403 Forbidden" responses, stop. Don't just keep hammering away at the server - it probably means that you've been banned for abusive behaviour and continuing to hammer away at the server will just extend your ban.

http://wiki.osm.org/wiki/Blocked

Torsten Römer
  • 3,834
  • 4
  • 40
  • 53
1

You can use this code to set the user agent

HttpClientFactory.setFactoryInstance(new IHttpClientFactory() {
    public HttpClient createHttpClient() {
        final DefaultHttpClient client = new DefaultHttpClient();
        client.getParams().setParameter(CoreProtocolPNames.USER_AGENT, "useragent");
        return client;
    }
});
Jannik
  • 36
  • 4
  • Hi there from 2021. For whose who still need to use osmdroid 4.x, to make it work on modern androids use this answer, and include lib ver.4 from https://hc.apache.org/downloads.cgi – djdance Mar 13 '21 at 12:20