5

I am using osmdroid for my mapping needs in Android. Until a few days ago, I could see the map and every thing was okay, but now every time my map activity starts, I get an empty map and the following trace:

 08-22 07:47:01.113: WARN/org.osmdroid.tileprovider.modules.MapTileDownloader(470): UnknownHostException downloading MapTile: /10/520/387 : java.net.UnknownHostException: Unable to resolve host "tile.openstreetmap.org": No address associated with hostname
08-22 07:47:01.133: WARN/org.osmdroid.tileprovider.modules.MapTileDownloader(470): UnknownHostException downloading MapTile: /10/516/387 : java.net.UnknownHostException: Unable to resolve host "tile.openstreetmap.org": No address associated with hostname
08-22 07:47:01.284: INFO/org.osmdroid.tileprovider.modules.MapTileModuleProviderBase(470): Tile loader can't continue
08-22 07:47:01.284: INFO/org.osmdroid.tileprovider.modules.MapTileModuleProviderBase(470): org.osmdroid.tileprovider.modules.MapTileModuleProviderBase$CantContinueException: java.net.UnknownHostException: Unable to resolve host "tile.openstreetmap.org": No address associated with hostname
08-22 07:47:01.284: INFO/org.osmdroid.tileprovider.modules.MapTileModuleProviderBase(470):     at org.osmdroid.tileprovider.modules.MapTileDownloader$TileLoader.loadTile(MapTileDownloader.java:197)
08-22 07:47:01.284: INFO/org.osmdroid.tileprovider.modules.MapTileModuleProviderBase(470):     at org.osmdroid.tileprovider.modules.MapTileModuleProviderBase$TileLoader.run(MapTileModuleProviderBase.java:239)
08-22 07:47:01.284: INFO/org.osmdroid.tileprovider.modules.MapTileModuleProviderBase(470):     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1081)
08-22 07:47:01.284: INFO/org.osmdroid.tileprovider.modules.MapTileModuleProviderBase(470):     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:574)
08-22 07:47:01.284: INFO/org.osmdroid.tileprovider.modules.MapTileModuleProviderBase(470):     at java.lang.Thread.run(Thread.java:1020)
08-22 07:47:01.284: INFO/org.osmdroid.tileprovider.modules.MapTileModuleProviderBase(470): Caused by: java.net.UnknownHostException: Unable to resolve host "tile.openstreetmap.org": No address associated with hostname
08-22 07:47:01.284: INFO/org.osmdroid.tileprovider.modules.MapTileModuleProviderBase(470):     at java.net.InetAddress.lookupHostByName(InetAddress.java:496)
08-22 07:47:01.284: INFO/org.osmdroid.tileprovider.modules.MapTileModuleProviderBase(470):     at java.net.InetAddress.getAllByNameImpl(InetAddress.java:277)
08-22 07:47:01.284: INFO/org.osmdroid.tileprovider.modules.MapTileModuleProviderBase(470):     at java.net.InetAddress.getAllByName(InetAddress.java:249)
08-22 07:47:01.284: INFO/org.osmdroid.tileprovider.modules.MapTileModuleProviderBase(470):     at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:136)
08-22 07:47:01.284: INFO/org.osmdroid.tileprovider.modules.MapTileModuleProviderBase(470):     at org.apache.http.impl.conn.AbstractPoolEntry.open(AbstractPoolEntry.java:164)
08-22 07:47:01.284: INFO/org.osmdroid.tileprovider.modules.MapTileModuleProviderBase(470):     at org.apache.http.impl.conn.AbstractPooledConnAdapter.open(AbstractPooledConnAdapter.java:119)
08-22 07:47:01.284: INFO/org.osmdroid.tileprovider.modules.MapTileModuleProviderBase(470):     at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:360)
08-22 07:47:01.284: INFO/org.osmdroid.tileprovider.modules.MapTileModuleProviderBase(470):     at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:555)
08-22 07:47:01.284: INFO/org.osmdroid.tileprovider.modules.MapTileModuleProviderBase(470):     at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:487)
08-22 07:47:01.284: INFO/org.osmdroid.tileprovider.modules.MapTileModuleProviderBase(470):     at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:465)
08-22 07:47:01.284: INFO/org.osmdroid.tileprovider.modules.MapTileModuleProviderBase(470):     at org.osmdroid.tileprovider.modules.MapTileDownloader$TileLoader.loadTile(MapTileDownloader.java:171)
08-22 07:47:01.284: INFO/org.osmdroid.tileprovider.modules.MapTileModuleProviderBase(470):     ... 4 more

this is how my onCreate code looks like:

    super.onCreate(savedInstanceState);
    this.me = this;
    this.mMapView = new MapView(this, 256);
    //this.mMapView = (MapView) findViewById(R.id.map);

    this.mMapView.setTileSource(TileSourceFactory.MAPNIK);
    this.mMapView.setClickable(true);
    this.mMapView.setBuiltInZoomControls(true);

    this.mMapView.getController().setZoom(10);
    this.mMapView.getController().setCenter(new GeoPoint(39.461078, 2.856445));

    //register BrodCastListener! - remember to unregister!
    IntentFilter filter = new IntentFilter();
    filter.addAction(UpdateRequester.ACTION);
    this.registerReceiver(this.mUpdateReciever, filter);

    //make map seen
    setContentView(this.mMapView);

}

and my manifest file has the following permissions:

<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.INTERNET" />

<uses-feature android:name="android.hardware.location.network" />
<uses-feature android:name="android.hardware.location.gps"
           android:required="true"/>
<uses-feature android:name="android.hardware.wifi" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"></uses-permission>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"></uses-permission>
<uses-permission android:name="android.permission.ACCESS_MOCK_LOCATION"></uses-permission>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"></uses-permission>

Has anyone encountered this, or do you have any idea what the problem is?
The weird thing is that it worked just fine and nothing has changed.

This problem is occurring using the emulator.

Solution:
All I had to do is go to the project run configurations (right click project->run as->run configuration) then android application, then go to the "target" tab and below under the "Additional Emulator Command Line Options" add:

-dns-server 8.8.8.8
omri
  • 169
  • 2
  • 12

1 Answers1

0

Basically the exception says that it can't resolve the online resource.

Are you sure your device is connected to Wifi or 3G?

Ilya Saunkin
  • 18,934
  • 9
  • 36
  • 50
  • well, i am using the emulator(forgot to mention that,sorry) how caan i check if its connected? – omri Aug 22 '11 at 08:50
  • emulator is connected by default i think. unless the flight mode is selected. – Ilya Saunkin Aug 22 '11 at 12:21
  • no,cant see it(flight mode isn't selected). plus when i go to wireless&network settings and click Wifi it says error (without any explanation).. and thank you both! – omri Aug 23 '11 at 06:21
  • actually if kurtzmarc can't help you then nobody can. – Ilya Saunkin Aug 23 '11 at 09:13
  • :). btw just to be clear no other website is loading in the browser – omri Aug 23 '11 at 12:35
  • ok, the problem you are facing is not osmdroid specific, but android connectivity in general. The following question gives a brilliant suggestion to turn on wifi and it did work for me like RIGHT NOW. http://stackoverflow.com/questions/2039964/how-to-connect-android-emulator-to-the-internet – Ilya Saunkin Aug 23 '11 at 13:47
  • 1
    Great! thank you very much! i just had to add -dns-server 8.8.8.8 – omri Aug 24 '11 at 06:02
  • awesome! you might post a n answer to your own problem just to clarify how you solved it. – Ilya Saunkin Aug 24 '11 at 06:09