使用Nominatim的OpenStreetMap POI - 错误

时间:2016-10-11 12:32:05

标签: osmdroid

我正在使用本教程:https://github.com/MKergall/osmbonuspack/wiki/Tutorial_2

我在我的项目中设置了此代码:

NominatimPOIProvider poiProvider = new NominatimPOIProvider();
ArrayList<POI> pois = poiProvider.getPOICloseTo(startPoint, "cinema", 50, 0.1);

但我得到一些错误:
NominatimPOIProvider中的NominatimPOIProvider(String)无法应用于()

  

java.lang.NoClassDefFoundError:解析失败:Lokhttp3 / Request $ Builder;                         在org.osmdroid.bonuspack.utils.HttpConnection.doGet(HttpConnection.java:65)                         在org.osmdroid.bonuspack.utils.BonusPackHelper.requestStringFromUrl(BonusPackHelper.java:70)                         在org.osmdroid.bonuspack.location.NominatimPOIProvider.getThem(NominatimPOIProvider.java:83)                         在org.osmdroid.bonuspack.location.NominatimPOIProvider.getPOICloseTo(NominatimPOIProvider.java:133)                         at x.x.UserArea.onCreate(UserArea.java:152)                         在android.app.Activity.performCreate(Activity.java:6876)                         在android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1135)                         在android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3207)                         在android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3350)                         在android.app.ActivityThread.access $ 1100(ActivityThread.java:222)                         在android.app.ActivityThread $ H.handleMessage(ActivityThread.java:1795)                         在android.os.Handler.dispatchMessage(Handler.java:102)                         在android.os.Looper.loop(Looper.java:158)                         在android.app.ActivityThread.main(ActivityThread.java:7229)                         at java.lang.reflect.Method.invoke(Native Method)                         在com.android.internal.os.ZygoteInit $ MethodAndArgsCaller.run(ZygoteInit.java:1230)                         在com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)                      引起:java.lang.ClassNotFoundException:没有找到类“okhttp3.Request $ Builder”

2 个答案:

答案 0 :(得分:1)

错误:

  NominatimPOIProvider中的NominatimPOIProvider(String)不能   适用于()

是由NominatimPOIProvider缺少非参数构造函数引起的。您需要指定将在发送给Nominatim服务提供商的标头中使用的用户代理。有关详细信息,请参阅this issueusage policy of openstreetmap

使用类似:

NominatimPOIProvider poiProvider = new NominatimPOIProvider("YourUserAgentSpecificForYourApplicationOrWhatever");

答案 1 :(得分:0)

解决了:

compile 'com.github.bumptech.glide:okhttp3-integration:1.4.0@aar'
compile 'com.squareup.okhttp3:okhttp:3.2.0'