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