5
我在Android中使用osmdroid來滿足我的映射需求。直到前幾天,我可以看到地圖,每一件事情是好的,但現在每天我的地圖活動開始的時候,我得到一個空的地圖和下面的跟蹤:osmdroid映射不可見
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
這是怎麼了我的onCreate代碼如下像:
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);
}
和我的清單文件具有以下權限:
<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>
有沒有人遇到過這種,或者你有任何想法的問題是什麼?
奇怪的是,它工作得很好,沒有任何改變。
使用模擬器發生此問題。
解決方案:
所有我需要做的就是去到項目運行配置(右鍵單擊項目 - >運行原樣>運行配置),那麼Android應用程序,然後進入「目標」選項卡及以下下「其他仿真器命令行選項」添加:
-dns-server 8.8.8.8
好吧,我正在使用模擬器(忘記提及,對不起)我怎麼能檢查它是否連接?我認爲默認連接模擬器 – omri
。除非選擇了飛行模式。 –
在模擬器中打開Web瀏覽器。它能看到http://www.openstreetmap.org/嗎? – kurtzmarc