【问题标题】:Cannot import Google Places PlacePicker into Android project无法将 Google Places PlacePicker 导入 Android 项目
【发布时间】:2016-06-27 21:36:16
【问题描述】:

我正在尝试编写一个简单的程序,该程序涉及使用PlacePicker 来捕获位置信息。但是,我的项目似乎无法解决必要的导入问题。

build.gradle:

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:23.3.0'
    compile 'com.google.android.gms:play-services-location:9.2.0'
    compile 'com.google.android.gms:play-services-maps:9.2.0'
}

活动:

import com.google.android.gms.location.places.Place; // "Place" is not resolved
import com.google.android.gms.location.places.ui.PlacePicker; // "ui" is not resolved
import com.google.android.gms.maps.model.LatLng;

LatLng 导入似乎有效,但其他两个无效。当我导入完整的com.google.android.gms:play-services:9.2.0 API 时,整个项目运行良好,但我想使用特定的 API 调用来减少不必要的库。

【问题讨论】:

  • “整个项目运行良好”是什么意思?你不是要导入完整的地图包吗?
  • @cricket_007 - 看起来我最初的问题有误。我的意思是说它只有在我导入完整的谷歌播放服务包(即地图、位置、身份验证、身份、健身等)时才有效,这是我不需要的大量库。我将编辑问题。

标签: android google-places-api


【解决方案1】:

在播放服务9.2.0 中,places API 不再位于location。这些现在在他们自己的 places 依赖项中。要解决这些问题,您应该将其添加到您的 build.gradle

implementation 'com.google.android.gms:play-services-places:9.2.0'

已回复here

【讨论】:

  • 太棒了。谢谢。
  • 这花了很长时间才弄清楚。我仍然很好奇,它是否在 Google Places API 'Getting Started' 页面上的某个地方这么说?
猜你喜欢
  • 1970-01-01
  • 2015-06-06
  • 1970-01-01
  • 2014-04-06
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多